EDITED VERSION
I am trying to create an example showing how to use the fft function to approximate the Fourier transform. My example is to calculate the Fourier transform of h(t) = 2*pi*exp(-2*pi*t)u(t). The analytic solution is H(f) = 1/(1+jf). Here is my code:
N=1024; % sample count
T=10; % h(t) very small for t > T
t=linspace(0,T,N); % N sample points
h=2*pi*exp(-2*pi*t); % low pass IR 1 Hz cut-off
H=T*fft(h)/N; % FFT calculation of Fourier transform
Hmag=abs(H(1:N/2)); % Magnitude calculation
Hphase=180*angle(H(1:N/2))/pi; % Phase in degrees
f=(0:N/2-1)/T; % frequency bins thru Nyquist freq
subplot(2,1,1);semilogx(f,20*log10(Hmag))grid onsubplot(2,1,2);semilogx(f,Hphase)grid on
The results are shown in my response to the answer to an earlier version of my question. The magnitude plot is fairly close to the analytic result, but the phase plot goes a bit crazy at higher frequencies. Where am I going wrong?
To repeat, my goal is to show the relationship between the FFT of a discrete time function and the Fourier transform of its continuous time counterpart. I expected a closer relationship.
Best Answer