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

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)

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

Thanks for your reply. I can understand that "the discrete integral (or summation) is done under the assumption of Ts = 1". Ts is always normalized. But, I still don't understand "the actual amplitude result for every frequency will be exactly 1/Ts times greater than the true result". Can you elaborate this statement in a little bit more detail? How do you come up with that conclusion? Thanks a lot.
Think about if you were going to integrate a function discretely by hand. In order to do this you need to figure out the area under your curve by breaking the curve into small little pieces, figuring out the area for each piece individually, and then sum all the areas. To figure out the area for each piece, you need to know the amplitude at each sample [i.e., f(x)] and the distance between each sample [i.e., dx]. In simple terms, you would find the area under each "piece" (assuming a rectangular shaped "piece") by multiplying f(x) and dx at each x, then you would sum up all the little pieces to approximate the integral over some finite interval. Or, since dx is constant between all your sample points, you can simply sum up all of you amplitudes [i.e., f(x)] and then multiply that sum by dx to get the total area. The sum of the amplitudes [where the amplitudes are f(t)*exp(-1i*2*pi*f*t) for some frequency "f"] is basically what the "fft" gives you at each frequency. Then it is your job to tell it what the sample interval [i.e., dx or dt] is in order to compute the true area [i.e., the true amplitude].
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?
That is pretty much correct.

Iniciar sesión para comentar.

Preguntada:

el 3 de Nov. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by