Expert Answer:
:
It seems the scaling in your formula for the analytic Fourier Transform is not quite correct. According to this Fourier Transform table on Wikipedia, the transform of the continuous time-domain signal
is
where in your case a=1
. Correspondingly, you should compare the FFT of the time domain signal
t=linspace(-5,5,N);
f=exp(-t.^2);
with the analytic Fourier Transform
F2 = sqrt(pi)*exp(-(pi*y).^2);
So, plotting the comparison with:
hold off;
plot(y,F2);
hold on;
plot(nu,abs(F),'r');
legend('analiticFT','FFT')
xlim([-5 5])
yields:
Now that we have establish a proper basis for comparison, we can look at why you are getting the oscillations in img 1
. Simply put, the reference Gaussian pulse f=exp(-t.^2);
you have generated has a peak at t=0
. The corresponding "zero" discrete time instant is naturally the first index in the array (index 1). However in your array, this peak appears at index N/2
. Under the Shift theorem, this causes an additional exp(-pi*j*k)
term in the frequency domain, responsible for the oscillations you are seeing. To fix this, you should shift back your Gaussian pulse with ifftshift
:
F=fftshift(fft(ifftshift(f)));