Finding Accurate Amplitude Using FFT

Greetings,
I have been working on code to use the FFT to find the amplitude of a signal. However, despite my best efforts to window I seem to get incorrect amplitudes. When I manually find Amplitude by inspecting the signal I get A = 63.7. When I use the following code I get A = 54.8. This is causing significant errors in my Bode plot.
I tried using a flat top window to maximize amplitude accuracy. My signal does not seem significantly noisy. I expected an amplitude much closer to the true value.
function Amplitude = Gaindb(x)
if size(x, 2) > 1
x = x';
end
x = x - mean(x);
N = length(x);
win = flattopwin(N);
x = fft(x.*flattopwin(N));
Amplitude = 2*max(abs(x))/N;
end
Regards, Andy

 Accepted Answer

Hi Andy,
When I run your code I get 14.5 for the answer, so I am not sure how you are getting 54.8. But the 14.5 is consistent with the Matlab definition of the flattop window. From the documentation, the flattop is a sum of cosines with certain coefficients, along with a constant coefficient a0 = .216. a0, the area of the window, is basically the amplitude reduction factor for the signal.
Without any windowing of x, the fft comes up with a signal amplitude of 67.1, and 67.1 x .216 = 14.5 which is consistent.
The Matlab window peaks out at a value of 1.
Wikipedia has an example a flattop window from SRS that multiplies all the coefficients by 4.639, so the window peaks out at that value and a0 = 1. For a continuous sinusoidal signal such as yours the resulting amplitude will be basically unchanged.

1 Comment

Ah, my understanding of windowing must have been my limiting factor. Thank you David!

Sign in to comment.

More Answers (0)

Products

Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!