简体   繁体   English

复FFT然后逆FFT MATLAB

[英]Complex FFT then Inverse FFT MATLAB

I am using the FFT function in Matlab in an attempt to analyze the output of a Travelling Wave Laser Model. 我在Matlab中使用FFT函数来尝试分析行波激光模型的输出。

The of the model is in the time domain in the form (real, imaginary), with the idea being to apply the FFT to the complex output, to obtain phase and amplitude information in the frequency domain: 模型的时域是(实数,虚数)形式,其思想是将FFT应用于复数输出,以获得频域中的相位和幅度信息:

%load time_domain field data
data = load('fft_data.asc');

% Calc total energy in the time domain
N = size(data,1);
dt = data(2,1) - data (1,1);
field_td = complex (data(:,4), data(:,5));


wavelength = 1550e-9;
df = 1/N/dt;
frequency = (1:N)*df;
dl = wavelength^2/3e8/N/dt;
lambda = -(1:N)*dl +wavelength + N*dl/2;

%Calc FFT
FT = fft(field_td);
FT = fftshift(FT);
counter=1;
phase=angle(FT);
amptry=abs(FT);
unwraptry=unwrap(phase);

Following the unwrapping, a best fit was applied to the phase in the region of interest, and then subtracted from the phase itself in an attempt to remove wavelength dependence of phase in the region of interest. 在展开之后,将最佳拟合应用于感兴趣区域中的相,然后从相本身中减去以试图去除感兴趣区域中相的波长依赖性。

for i=1:N % correct phase and produce new IFFT input
    bestfit(i)=1.679*(10^10)*lambda(i)-26160;
    correctedphase(i)=unwraptry(i)-bestfit(i);
    ReverseFFTinput(i)= complex(amptry(i)*cos(correctedphase(i)),amptry(i)*sin(correctedphase(i)));
end

Having performed the best fit manually, I now have the Inverse FFT input as shown above. 手动执行最佳拟合后,我现在具有如上所示的反向FFT输入。

pleasework=ifft(ReverseFFTinput);

from which I can now extract the phase and amplitude information in the time domain: 我现在可以从中提取时域中的相位和幅度信息:

newphasetime=angle(pleasework);
newamplitude=abs(pleasework);

However, although the output for the phase is greatly different compared to the input in the time domain 但是,尽管相位输出与时域输入相比有很大不同

蓝色=反向FFT后的时域相位输出

the amplitude of the corrected data seems to have varied little (if at all!), 校正数据的幅度似乎变化不大(如果有的话)!

在此输入图像描述在此输入图像描述

despite the scaling of the phase. 尽管阶段缩放。 Physically speaking this does not seem correct, as my understanding is that removing wavelength dependence of phase should 'compress' the pulsed input ie shorten pulse width but heighten peak. 从物理上讲这似乎不正确,因为我的理解是去除相位的波长依赖性应该“压缩”脉冲输入,即缩短脉冲宽度但提高峰值。

My main question is whether I have failed to use the inverse FFT correctly, or the forward FFT or both, or is this something like a windowing or normalization issue? 我的主要问题是我是否未能正确使用逆FFT,或者前向FFT或两者兼有,或者这类似于窗口化还是归一化问题?

Sorry for the long winded question! 对不起,这个冗长的问题! And thanks in advance. 并提前感谢。

You're actually seeing two effects. 你实际上看到了两种效果。

First the expected one goes. 首先是预期的一个。 You're talking about "removing wavelength dependence of phase". 你在谈论“消除相位的波长依赖性”。 If you did exactly that - zeroed out the phase completely - you would actually get a slightly compressed peak. 如果你做到了 - 完全将相位归零 - 你实际上会得到一个稍微压缩的峰值。 What you actually do is that you add a linear function to the phase. 你实际做的是为相位添加线性函数。 This does not compress anything; 这不会压缩任何东西; it is a well-known transformation that is equivalent to shifting the peaks in time domain. 这是一个众所周知的转变,相当于在时域中移动峰值。 Just a textbook property of the Fourier transform. 只是傅立叶变换的教科书属性。

Then goes the unintended one. 然后是非预期的一个。 You convert the spectrum obtained with fft with fftshift for better display. 您可以使用fftshiftfft获得的光谱转换为更好的显示效果。 Thus before using ifft to convert it back you need to apply ifftshift first. 因此,在使用ifft将其转换回来之前,您需要首先应用ifftshift As you don't, the spectrum is effectively shifted in frequency domain. 如果不这样做,频谱在频域中有效地移位。 This results in your time domain phase being added a linear function of time, so the difference between the adjacent points which used to be near zero is now about pi. 这导致您的时域相位被添加为时间的线性函数,因此过去接近零的相邻点之间的差异现在大约为pi。

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

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