I have this function in time-domain and in frequency domain after fourier transform:
$$s_1(t) = (t-2)e^{-t}u(t-2) $$
$$S_1(f)=\frac{e^{-2(1+j2\pi f)}}{(1+j2\pi f)^2} $$
First I create a time vector and a frequency vector ranging from [0s,8s) and [-50hz,50hz) respectively and evaluate them on my functions, using these lines:
s1=(t1-2).*exp(-t1).*heaviside(t1-2); %s1(t)
S1f=(exp(-2*(1+(2*pi*f1*1i)))./((1+(2*pi*f1*1i)).^2)); %S1(f)
What I get when plotting magnitude/phase is this:
After that, I wanted to compare those results using FFT command in Matlab, so I did this:
S1k=fft(s1);
figure % creates a figure
subplot(2,1,1) %creates a grid of 2 plots in one figure, selecting the stem as the first plot
stem(k1,abs(fftshift(S1k,2)),'red') %plots magnitude of S1f
title('Magnitude vs Frequency')
subplot(2,1,2) %selects the phase plot as the second one in the grid
plot(k1,angle(fftshift(S1k,1)),'blue') %plots magnitude of S1f
title('Phase vs Frequency')
And the result, to my surprise, is this:
As you can tell, there are plenty of differences in both plots, though "shape" its similar at least in the magnitude plot, but with different values in the y-axis.
What can be the problem? I'm sure the fourier transform I did by hand is good, but yet results are different.
Why? Isn't FFT and DFT similar except for the speed of calculation?
Any hints will be appreciated.