Correct frequency axis using FFT

笑着哭i 提交于 2019-12-20 04:35:48

问题


How can I get the correct frequency vector to plot using the FFT of MATLAB?

My problem:

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));

Normally I'd do this :

 f = f     = Fs/Nsamples*(0:Nsamples/2-1); % Prepare freq data for plot

The problem is this time I do not have a Fs (sample frequency).

How can I do it correctly in this case?


回答1:


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".

Edit

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;


来源:https://stackoverflow.com/questions/48373100/correct-frequency-axis-using-fft

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!