understand difference between analytic result of Fourier transform and result of fft() function
5 views (last 30 days)
Show older comments
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.
0 Comments
Answers (2)
Dr. Seis
on 3 Nov 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 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!