问题描述
如何使用MATLAB
的 FFT 绘制正确的频率矢量?
How can I get the correct frequency vector to plot using the FFT of MATLAB
?
我的问题:
N = 64;
n = 0:N-1;
phi1 = 2*(rand-0.5)*pi;
omega1 = pi/6;
phi2 = 2*(rand-0.5)*pi;
omega2 = 5*pi/6;
w = randn(1,N); % noise
x = 2*exp(1i*(n*omega1+phi1))+4*sin(n*omega2+phi2);
h = rectwin(N).';
x = x.*h;
X = abs(fft(x));
通常我会这样做:
f = f = Fs/Nsamples*(0:Nsamples/2-1); % Prepare freq data for plot
问题是这一次我没有Fs(采样频率).
The problem is this time I do not have a Fs (sample frequency).
在这种情况下如何正确执行?
How can I do it correctly in this case?
推荐答案
如果您没有 Fs ,只需将其设置为1(如每个样本一个样本).这是我一直使用并看到其他所有人使用的典型解决方案.您的频率从0到1(或-0.5到0.5),没有单位.每个人都将其理解为每个样本的期间".
If you don't have a Fs, simply set it to 1 (as in one sample per sample). This is the typical solution I've always used and seen everybody else use. Your frequencies will run from 0 to 1 (or -0.5 to 0.5), without units. This will be recognized by everyone as meaning "periods per sample".
修改
根据您的评论,我得出结论,您对径向频率感兴趣.在这种情况下,您想将绘图的x轴设置为
From your comment I conclude that you are interested in radial frequencies. In that case you want to set your plot x-axis to
omega = 2*pi*f;
这篇关于使用FFT校正频率轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!