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

 채택된 답변

David Goodmanson
David Goodmanson 2018년 5월 22일

0 개 추천

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

Andy MacDonald
Andy MacDonald 2018년 5월 22일
Ah, my understanding of windowing must have been my limiting factor. Thank you David!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

제품

릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by