Why fft amplitude changes when the signal's length changes?

22 次查看(过去 30 天)
Hi. I would like to know the relationship between the lenght of a signal and its amplitude in frequency domain. I am using a sample code to take the fourier transform of 3 cosine waveforms and recording its amplitudes. However, I have noticed that when I change the length of the signal, the amplitude changes too and I would like to know why. For example, if L = 1000 the amplitudes of the 3 waveforms in frequency domain will be different to the ones when L =2000 and so on.
Thanks in advance! the code that I am using is the following:
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sampling period
L = 1000; % Length of signal
t = (0:L-1)*T; % Time vector
x1 = cos(2*pi*100*t);
x2 = 2*cos(2*pi*100*t); % Second row wave
x3 = 4*cos(2*pi*100*t); % Third row wave
X = [x1; x2; x3];
for i = 1:3
subplot(3,1,i)
plot(t(1:100),X(i,1:100))
title(['Row ',num2str(i),' in the Time Domain'])
end
n = 2^nextpow2(L);
dim = 2;
Y = fft(X,n,dim);
P2 = abs(Y/n);
P1 = P2(:,1:n/2+1);
P1(:,2:end-1) = 2*P1(:,2:end-1);
figure(2)
for i=1:3
subplot(3,1,i)
plot(0:(Fs/n):(Fs/2-Fs/n),P1(i,1:n/2))
title(['Row ',num2str(i), ' in the Frequency Domain'])
end

回答(1 个)

Honglei Chen
Honglei Chen 2017-6-21
This is because fft by default does not normalize the power. You can think the result of fft is adding signal samples together so the longer the signal is, the larger the sum if they are adding together coherently. If you want to see the frequency component, you will have to normalize it, like shown in the following example
HTH
  2 个评论
Ale
Ale 2017-6-22
Hello, I am not sure how to normalize the frequency. I have been trying to follow the example you left in your comment but I am not getting the expected answer. The figure in the left shows the amplitude in frequency domain with L=1000 and the right one is L=2000. As you can see the amplitude changes and as I increase more and more the difference between them gets bigger.
Can you explain me how should I normalize the frequency to have a constant amplitude regardless of the signal's length? Thanks.
Honglei Chen
Honglei Chen 2017-6-22
I'll try to write a bit more later. But note that in your comparison, the frequency axis are not the same, so you are not comparing apple to apple. I would say that you fix your frequency axis, say always use 2048 as the number of FFT points and then do the comparison.
HTH

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by