Recover gaussian by using fft and ifft.

5 visualizaciones (últimos 30 días)
Mikhail
Mikhail el 30 de Dic. de 2014
Respondida: Youssef Khmou el 30 de Dic. de 2014
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;
%--------------------------------------------------------------------------

Respuestas (1)

Youssef  Khmou
Youssef Khmou el 30 de Dic. de 2014
Try :
G(end)=[];
G=(sqrt(2*pi))*G;
figure; plot(t,f,'r',t,G,'g');

Categorías

Más información sobre Fourier Analysis and Filtering en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by