Matlab的快速傅立叶变换/ FFT时间和速度 [英] Matlab Fast Fourier Transform / fft for time and speed

查看:544
本文介绍了Matlab的快速傅立叶变换/ FFT时间和速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有数据的子集的时间和速度,像这样一个2列向量:

I have a 2 column vector with times and speeds of a subset of data, like so:

5 40
10 37
15 34
20 39

等。我想要得到的傅里叶变换速度得到的频率。我怎么会去用快速傅立叶这样变换(FFT)?

And so on. I want to get the fourier transform of speeds to get a frequency. How would I go about doing this with a fast fourier transform (fft)?

如果我的矢量的名字是sampleData在,我已经试过

If my vector name is sampleData, I have tried

fft(sampleData);

但是,让我实数和虚数的矢量。为了能够得到合理的数据绘制的,我怎么会去这样做?

but that gives me a vector of real and imaginary numbers. To be able to get sensible data to plot, how would I go about doing this?

推荐答案

傅立叶变换将产生一个复杂的矢量,当你FFT你得到频率的矢量,每个人都有一个光谱相位。这些阶段可以是非常重要的! (它们包含大部分的时域信号的信息,你不会看到没有他们等干扰效应...)。如果你要绘制的功率谱,可以

Fourier Transform will yield a complex vector, when you fft you get a vector of frequencies, each has a spectral phase. These phases can be extremely important! (they contain most of the information of the time-domain signal, you won't see interference effects without them etc...). If you want to plot the power spectrum, you can

plot(abs(fft(sampleData)));

要完成这个故事,你可能需要fftshift,并且还产生一个频率向量。下面是一个更复杂的code:

To complete the story, you'll probably need to fftshift, and also produce a frequency vector. Here's a more elaborate code:

% Assuming 'time' is the 1st col, and 'sampleData' is the 2nd col: 
N=length(sampleData);  
f=window(@hamming,N)';
dt=mean(diff(time)); 
df=1/(N*dt); % the frequency resolution (df=1/max_T)
if mod(N,2)==0
    f_vec= df*((1:N)-1-N/2); % frequency vector for EVEN length vector
    else
    f_vec= df*((1:N)-0.5-N/2); 
end

fft_data= fftshift(fft(fftshift(sampleData.*f))) ;

plot(f_vec,abs(fft_data))

这篇关于Matlab的快速傅立叶变换/ FFT时间和速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆