Correct frequency axis using FFT

2019-03-02 17:46发布

问题:

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;