matlab中的离散傅里叶变换用于数据?

时间:2012-04-02 05:25:47

标签: matlab fft

我在时域中有一些数据,每个元素之间的时间间隔为dt,我的数据从0到N * dt秒,我想看到我的数据频谱从.6e15 Hz到1e15 Hz我该怎么办? ?

2 个答案:

答案 0 :(得分:1)

假设你已经及时了x。

x%is given
fmin = 1e15;
fmax = 6*fmin;
numOfSamples = length(x);
f = linspace(fmin,fmax,numOfSamples);
t = 1 : numOfSamples;
y=fft(x);
plot(fftshift(y));

答案 1 :(得分:0)

以下是我需要的代码:

NT=10000;%size of data that I have
ddx=2e-9;
dt=ddx/(3e8);%time separation between each element
i=sqrt(-1);
NFREQS=1000;%size of frequency array
lambdai=150e-9;
lambdaf=500e-9;
freqi=3e8/lambdai;%lower limit of frequency
freqf=3e8/lambdaf;%upper limit of frequency
freq=zeros(1,NFREQS);
for j=1:NFREQS
freq(j)=freqi-j*(freqi-freqf)/NFREQS;%frequency array
end
arg=2*pi*freq*dt;
lambda=linspace(lambdai,lambdaf,NFREQS);
    for n=1:NFREQS
    for j=1:NT
     Exf(n)=Exf(n)+Ex(j)*exp(-i*arg(n)*j);%Ex the data that I have and Exf is fft of it
    end
    end

plot(lambda,real(Epsilon));

此代码计算Ex的傅立叶变换,范围为150e-9m t0 500e-9m