Inverse fast fourier transform in MATLAB

瘦欲@ 提交于 2019-12-20 05:39:20

问题


My MATLAB code for fft and ifft below has a problem with the inverse Fourier signal y not matching the in put signal x. Is there any solution to resolve this?

N = 1000;
t0 = 1e-13;
tau = 2*1e-14;
n = [0:t0/40:2*1e-13-t0/40];
f0 = 3*1e8/(150*1e-9);

x = cos(2*pi*f0*n);
x = x.*exp((-(n-t0).^2)./(tau^2));
X = abs(fft(x,N));
F = [-N/2 : N/2 - 1]/N;
X = fftshift(X);
y=ifft(X,80);

figure(3)
plot(n,y)

回答1:


I see a number of issues here:

N = 1000;
t0 = 1e-13;
tau = 2*1e-14;
n = [0:t0/40:2*1e-13-t0/40];
f0 = 3*1e8/(150*1e-9);

x = cos(2*pi*f0*n);
x = x.*exp((-(n-t0).^2)./(tau^2));
%  X = abs(fft(x,N));  <-- Not seen this technique before, and why N=1000?
% try something more like:
X = fft(x);

F = [-N/2 : N/2 - 1]/N;
% this is fine to shift and plot the function
Xshifted = fftshift(X);
plot( abs( Xshifted ) )
% now you're taking the inverse of the shifted function, not what you want
% y=ifft(X,80);  also not sure about the 80
y = ifft(X);

figure(3)
plot(n,y)
figure(4)
plot( n, x ); hold on; plot( n, y, 'o' )

That's all I see at first. HTH!




回答2:


If you take the absolute value of the fft, you destroy the phase information needed to reconstruct the original signal, i.e. the moment you compute

X = abs(fft(x,N));

You cannot go back via ifft, because now you only have the magnitude. Also, the inverse transformation only works if you use the same number of FFT bins with NFFT>=length(x).

y=ifft(fft(x)); 

should be exactly the same as x.



来源:https://stackoverflow.com/questions/15032178/inverse-fast-fourier-transform-in-matlab

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!