Huge difference between the result of fft function Matlab and analytical Fourier transform of the same function
45 views (last 30 days)
Show older comments
Commented: Shaily_T on 15 Sep 2022
I am trying to find a way to obtain the numerical fourier transform of a function (it is not a signal and I only want to obtain the numerical fourier transform of a function). For a test code, I tried to see what is the result of fft matlab for a Gaussian function and compared it with the analytical fourier transform of this Gaussian. I have attached the plot of both results. Why the amplitude of fft result is that huge compared to analytical result? I can use fftshift to shift the result of fft to center but still the issue of amplitudes are there. I am wondering isn't it because it is a Gaussian function and so not periodic over time? Does fft only works if the function we have is spanned from -infinity to +infinity (basically a signal)? or we can use it if we want ot calculate the fourier transform of a function which spans from t-1 to t-2?
Paul on 11 Sep 2022
Can't say for sure w/o seeing the code, but I supsect the fftshifted curve will be close to the blue curve if you mulitply the fftshifted result by the sampling period.
More Answers (1)
David Goodmanson on 11 Sep 2022
Edited: David Goodmanson on 11 Sep 2022
Your frequency grid runs from -5 to 5, which for an fft is -fs/2 to fs/2 (fs being the sampling frequency), so fs = 10. The sampling interval delta_t = 1/fs = 1/10. It appears that you are trying to approximate a continuous Riemann integral
Int g(t) e^(-2pi i f t) dt
by using the fft. That approximation is a sum over indices (done by the fft) times the width of the intervals.
Sum (stuff) * delta_t
So if you multiply by 1/10, that takes the fft result down by exactly the right amount.
Find more on Transforms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!