MATLAB 中的 FFT:错误的 0Hz 频率
我想在 MATLAB 中使用 fft 来分析一些保存为 Excel 文件的实验数据。 我的代码:
A=xlsread('Book.xls'); G=A'; x=G(2, : );
N=length(x);
F=[-N/2:N/2-1]/N;
X = abs(fft(x-mean(x),N))
X = fftshift(X);
plot(F,X)
但它绘制了一个带有大量 0Hz 错误分量的图表,我的真实频率约为 395Hz,并且它没有显示在绘制的图表中。 请告诉我出了什么问题。
任何帮助将不胜感激。
I want to use fft in MATLAB to analize some exprimental data saved as an excell file.
my code:
A=xlsread('Book.xls'); G=A'; x=G(2, : );
N=length(x);
F=[-N/2:N/2-1]/N;
X = abs(fft(x-mean(x),N))
X = fftshift(X);
plot(F,X)
But it plots a graph with a large 0Hz wrong component, my true frequency is about 395Hz and it is not shown in the plotted graph.
Please tell me what is wrong.
Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设我们从文件中读取信号:
首先我们从时间轴估计采样频率,并构建频率向量:
然后计算 FFT 并绘图:
最后找到峰值和相应的频率:
您可能需要放大到更清楚地看到事物的起源:
Assume we read the signal from file:
First we estimate the sampling frequency from the time axis, and build the frequency vector:
then compute the FFT and plot:
finally find the peak and the corresponding frequency:
you might want to zoom-in near the origin to see things more clearly: