Why fft amplitude changes when the signal's length changes?
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponses (1)
Honglei Chen
le 21 Juin 2017
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 commentaires
Honglei Chen
le 22 Juin 2017
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
Voir également
Catégories
En savoir plus sur Fourier Analysis and Filtering dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!