Discrete Fourier transform of real valued Gaussian using FFT
16 次查看(过去 30 天)
显示 更早的评论
Hi all,
I have a question regarding the computation of the discrete Fourier transfrom of a real valued Gaussian function using the FFT routine in MATLAB. First I define the discrete grids in time and frequency
% grid in time
tn = linspace(-10.0,10.0,128);
% grid in frequency
fn = tn/(20.0*20.0/128);
% Gaussian function in t-domain
gauss = exp(-tn.^2);
The Gaussian function is shown below

The discrete Fourier transform is computed by
fftgauss = fftshift(fft(gauss));
and shown below (red is the real part and blue is the imaginary part)

Now, the Fourier transform of a real and even function is also real and even. Therefore, I'm a bit surprised by the somewhat significant nonzero imaginary part of fftgauss. What is more surprising to me is the oscillations in the real part of fftgauss --- is this due to the discreteness of the transform? The continuous Fourier transform of a real valued Gaussian function is a real valued Gaussian function too...
In order to answer this question, I have written a simple discrete Fourier transform, see below
dftgauss = zeros(128);
for n = 1:128
for m = 1:128
dftgauss(n) = dftgauss(n) + gauss(m)*exp(2.0*pi*i*fn(n)*tn(m));
end
end
and dftgauss is shown below

Clearly, fftgauss and dftgauss are different, though the real part of dftgauss is equal to abs(fftgauss). My discrete Fourier transform actually gives the result that I expected (The continuous Fourier transform of a real valued Gaussian function is a real valued Gaussian function too...).
In short: Why is the real part of fftgauss oscillating?
0 个评论
采纳的回答
Greg Heath
2012-6-17
If T = N*dt and Fs = 1/T.
t = linspace(- (T - dt)/2 , (T - dt)/2 , N ) % N odd
or
t = linspace( - T/2 , T/2 - dt , N ) % N even
and
f = linspace(- (Fs - df)/2 , (Fs - df)/2 , N ) % N odd
or
f = linspace( - Fs/2 , Fs/2 - df , N ) % N even
Then
X = fftshift(fft(ifftshift(x)))
Hope this helps.
Greg
5 个评论
Morgane Borreguero
2016-10-12
Sorry Greg I don't understand your Notation. Could you maybe help me or use the same Notation than Jakob Petersen? I would be gratefull. What are you T and N and so on?
Greg Heath
2016-10-17
Fs = 1/dt = N/T = N*df
N time points equally spaced over the temporal period T with spacing dt = T/N
are mapped into N frequency points equally spaced over the spectral period Fs with spacing df = Fs/N
This is standard notation for Fourier Series.
See any Fourier series reference.
Hope this helps.
Greg
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spectral Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!