Recover gaussian by using fft and ifft.

조회 수: 5 (최근 30일)
Mikhail
Mikhail 2014년 12월 30일
답변: Youssef Khmou 2014년 12월 30일
I am trying to recover gaussian by using fft and ifft. But the result is correct only in case of the analytical fft. Please give me advice what should I do in discrete case.
clear all;
T=10;
N=256;
dt=T/(N-1);
t=linspace(-T/2,T/2,N);
f=exp(-t.^2);
g=sqrt(pi).*exp(-(pi^2).*t.^2);
F=fft(fftshift(f))*dt;
F1=F(1:N/2+1);
F2=F(N/2+1:N);
F=[F2,F1];
dnu=(N-1)/(N*T);
nuNyq=1/(2*dt);% Nyquist frequency
nu=-nuNyq+dnu*(0:N);
% plot(t,g);
% plot(nu(N/2+1-20:N/2+1+20),real(F(N/2+1-20:N/2+1+20)));
%------------ifft of analitical Fourier transform--------------------------
Z=ifft(ifftshift(g))*N*dt;
Z1=Z(1:N/2+1);
Z2=Z(N/2+1:N);
Z=[Z2,Z1];
figure
hold on;
plot(t,f);
plot(nu(N/2+1-20:N/2+1+20),real(Z(N/2+1-20:N/2+1+20)));
hold off;
%--------------------------------------------------------------------------
%----------------ifft of discrete Fourier transform------------------------
G=ifft(ifftshift((F)))*dt*N;
G1=G(1:N/2+1);
G2=G(N/2+1:N);
G=[G2,G1];
figure
hold on;
plot(t,f);
plot(nu(N/2+1-20:N/2+1+20),real(G(N/2+1-20:N/2+1+20)));
hold off;
%--------------------------------------------------------------------------

답변 (1개)

Youssef  Khmou
Youssef Khmou 2014년 12월 30일
Try :
G(end)=[];
G=(sqrt(2*pi))*G;
figure; plot(t,f,'r',t,G,'g');

카테고리

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