FFT,但具有线性波长范围

时间:2017-03-12 18:12:12

标签: matlab fft

当在Matlab中对时间 u 的函数执行FFT时,返回复杂的光谱 uf 。为了将频谱幅度 abs(uf)与其频率成分进行对比,可以使频率网格适应 uf 。我可以将波长网格与频率网格相关联,并将 uf 与之对应。频率阵列中每个元件之间的间隔是恒定的,但是由于波长~1 /频率,波长阵列中每个点之间的间隔在阵列索引上变化。我很好奇是否有办法采用时间函数的FFT来产生波长恒定的光谱。这是我在Matlab中的代码:

clc;
close all;
clear all;

lam = 800e-9; % Wavelength (m)
c = 3e8; % Light speed (m/s)

nt = 8192; % Temporal grid resolution
T = 400*1e-15; % Temporal grid size (s)
dt = T/nt; % Temporal pixel spacing

df = 1/(nt*dt); % Frequency pixel spacing
ff = [(0:nt/2-1) (-nt/2:-1)]*df; % Frequency grid 
ff = fftshift(ff); 

wav = c./ff; % Wavelength array (spacing is not constant between each element)

for k = 1:nt
    tt(k) = (-nt/2+k-1)*dt; % Time array
    u(k) = cos(2*pi*c/lam*tt(k)); % Function of time
end

%Now I can take FFT:

uf = fftshift(fft(u)); % The spectrum of my function. The FFT has yielded a spectrum associated with a frequency array of linearly spaced elements (ff).

光谱幅度与波长和频率的关系曲线都能产生良好的结果。

figure(1)
plot(ff,abs(uf)) 
title('Spectral amplitude vs frequency')
xlabel('Frequency (Hz)')
ylabel('Spectral amplitude')

figure(2)
plot(wav,abs(uf))
title('Spectral amplitude vs wavelength')
xlabel('Wavelength (m)')
ylabel('Spectral amplitude');

enter image description here

但我的波长数组没有恒定的间距:

figure(3)
plot(ff)
title('Frequency array')
ylabel('Frequency (Hz)')
xlabel('Index')

figure(4)
plot(wav)
xlim([(nt/2 +1) (nt/2 + 100)])
title('Wavelength array')
ylabel('Wavelength (m)')
xlabel('Index')

enter image description here

1 个答案:

答案 0 :(得分:2)

你应该制作一个线性间隔的波长数组并插入你的数据以找到线性间隔的y值。