understand difference between analytic result of Fourier transform and result of fft() function

5 visualizaciones (últimos 30 días)
Hi, I have a piece of code to show the difference between analytical result of Fourier Transform and the numeric result of built-in function - fft() in Matlab. The code is cut and paste below.
N=128;
t=linspace(0,3,N);
f=2*exp(-3*t);
Ts=t(2)-t(1);
Ws=2*pi/Ts;
F=fft(f);
Fp=F(1:N/2+1)*Ts;
W=Ws*(0:N/2)/N;
Fa=2./(3+j*W);
plot(W,abs(Fa),'*',W,abs(Fp),'+');
xlabel('Frequency, Rad/s'), ylabel('|F(w)|');
If you run the above code, you will see two curves in the plot. They match quite well. Basically, this program is to plot the analytical result and numeric result of Fourier Transform for function of following.
f(t) = 12exp(-3t) when t > 0. f(t) = 0 when t < 0.
The analytical Fourier transform of the above function is given below.
f(W) = 12/(3+jW)
In the above code, both Fa and Fp is plotted versus W. W is rad/s, and is ranged between (0, Ws/2). Ws is the sampling frequency for array f. The part that I don't understand in the above code is the line "Fp=F(1:N/2+1)*Ts;". Why does it need to multiply Ts with F to get the result of Fourier Transform, namely F(W)? If I took out that multiplcation, namely, change that line to "Fp=F(1:N/2+1)", then the two curves do not match any more. Can anyone help answer that? Thanks.

Respuestas (2)

Dr. Seis
Dr. Seis el 3 de Nov. de 2011
Since the "fft" has no idea what the time increment (i.e., Ts) of your data is, the result you are given basically assumes your data are sampled once every second. Therefore, because the discrete integral (or summation) is done under the assumption of Ts = 1, the actual amplitude result for every frequency will be exactly 1/Ts times greater than the true result.
  4 comentarios
Tieling
Tieling el 4 de Nov. de 2011
OK, it seems to make sense. So you are saying that, fft always assumes dt is 1. But, the true result is that, dt = Ts. So now, in order to get the true area, you need to multiply fft result by Ts. Do I understand correct?

Iniciar sesión para comentar.


Tieling
Tieling el 3 de Nov. de 2011
Anyone have any comment? Thanks.

Community Treasure Hunt

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

Start Hunting!

Translated by