简体   繁体   English

MATLAB:将信号FFT转换为频率,然后将IFFT转换回时域,不完全是第一个信号

[英]MATLAB: FFT a signal to frequency and IFFT back to time domain, not exactly the first signal

I am trying to reproduce the changes on a ~30 femtosecond laser pulse. 我试图重现约30飞秒激光脉冲的变化。 I create and display this pulse in time just fine. 我创建并及时显示此脉冲。 Also, the fft of this pulse apperas fine on matlab (central frequency and width are very fine). 此外,在Matlab上此脉冲的fft值也很好(中心频率和宽度非常好)。 But when I backtransform the transformed one using the ifft() function, the pulse is moved in time (posssibly due to phase change?? I don't know) and also the peak maxima are different.. What could be the cause of this? 但是,当我使用ifft()函数对转换后的波形进行逆变换时,脉冲会随时间移动(可能是由于相位变化?我不知道),并且峰值最大值也有所不同。 ? I am using ifft the wrong way? 我使用错误的ifft方法?

The code I am using is this : 我正在使用的代码是这样的:

    atto=1e-18;
c = 299792458;
femto=1e-15;
lamda0=800e-9;
f_0=c/lamda0;
omega0=2*pi*c/lamda0;
T=2*pi/omega0;
a=2*log(2)/((36.32*femto)^2);
Fs=3/atto; %samplying rate
t=-200*femto:1/Fs:200*femto;
Efield=exp(-a.*(t-T).^2).*exp(1j.*omega0.*(t-T));

nfft=2^nextpow2(length(Efield));
Efieldfft=fft(Efield,nfft);
f=(0:nfft-1)*Fs/nfft;
omega=2*pi*f;
figure(1)
plot(t,Efield)
xlabel('s [fs]')
ylabel('Amplitude')

figure(2)
plot(omega,abs(Efieldfft))
xlim([2e15 2.8e15])
xlabel('omega [rad]')
ylabel('Amplitude')

figure(3)
plot(f,abs(Efieldfft))
xlim([3.3e14 4.1e14])
xlabel('frequency [Hz]')
ylabel('Power')

test=ifft(Efieldfft,length(t));

figure(4)
plot(t,test)
xlabel('s[fs]')
ylabel('amplitude')

That's because you are modifying the length of the FFT compared with the length of your time axis. 这是因为与时间轴的长度相比,您正在修改FFT的长度。 To see this, replace 要看到这个,更换

nfft=2^nextpow2(length(Efield));

by 通过

nfft=length(Efield);

You'll find that figures 1 and 4 are now equal, up to numerical precision errors. 您会发现图1和图4现在相等,直到数值精度误差为止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM