필터 지우기
필터 지우기

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

조회 수: 22 (최근 30일)
Ale
Ale 2017년 6월 21일
댓글: Honglei Chen 2017년 6월 22일
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

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

카테고리

Help CenterFile Exchange에서 Discrete Fourier and Cosine Transforms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by