フィルターのクリア

Recover gaussian by using fft and ifft.

1 回表示 (過去 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 Center および File ExchangeFourier Analysis and Filtering についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by