FFT result looks nothing like analytic result

조회 수: 2 (최근 30일)
James Kirk
James Kirk 2015년 11월 29일
편집: Rick Rosson 2016년 3월 14일
Forgive me if I am missing understanding something simple here but I am confused by exactly what the FFT function returns in Matlab. I have code to compare the result of FFT to the analytic result of the fourier transform of a gaussian:
steps = 2^10; lim = 4;
x = linspace(-lim, lim, steps);
w = lim/4; A = 1;
func = A*exp((-1).*(x./w).^2); % Gaussian
Analytic = sqrt(pi)*w*exp(-(w*pi.*x).^2); % Analytic Transform
Func = fftshift(fft(func)); % FFT transform
When I plot this, the fft function looks nothing like the analytic result:
If anyone could shed some light on why this is and how I can adapt my use of the FFT function to give me back the analytic result I would greatly appreciate it!
I am asking this question as I have been developing some code to model the propagation of various beams through a turbulent medium using phase screens. For the code to be valid it is important that the Fourier Transforms produced agree with Physics.

답변 (1개)

Rick Rosson
Rick Rosson 2016년 1월 6일
편집: Rick Rosson 2016년 3월 14일
steps = 2^10; lim = 4;
dx = 2*lim/steps;
x = -lim:dx:lim-dx;
% x = linspace(-lim, lim, steps);
Fs = 1/dx;
dF = Fs/steps;
f = -Fs/2:dF:Fs/2-dF;
w = lim/4; A = 1;
func = A*exp((-1).*(x./w).^2); % Gaussian
% Analytic = sqrt(pi)*w*exp(-(w*pi.*x).^2); % Analytic Transform
Analytic = sqrt(pi)*w*exp(-(w*pi.*f).^2);
% Func = fftshift(fft(func)); % FFT transform
Func = dx*fftshift(fft(ifftshift(func))); % FFT transform
diff = abs(Func) - Analytic;
figure;
subplot(2,1,1);
plot(f,abs(Func),f,Analytic);
xlim([-4 4]);
subplot(2,1,2);
plot(f,diff);
xlim([-4 4]);
  댓글 수: 2
Luna
Luna 2016년 2월 29일
편집: Luna 2016년 2월 29일
Dear Rick,
I have troubles with exactly the same problem. I just tested your code and it produces, as in James example, an output fft function that do not agree with the analytical one. Can you explain why? Is there a reason? Thank you very much
Luna
Rick Rosson
Rick Rosson 2016년 3월 14일
They are the same to within +/- 3 x 10^-8.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by