# How to take the FFT in a limited range of frequencies?

When using the fft function in Matlab to take the Fourier transform, one can specify the number of FFT points, nfft, and the command is written fft(x,nfft). In this case, what is the frequency vector?

How can the Fourier transform be calculated with the same nfft, but over a narrower range of frequencies? How would the frequency vector be calculated?

• Check out the Chirp-Z-transform. You can find some information about it in this answer. – Matt L. Nov 8 '14 at 22:42

If your sampling frequency is $f_s$, and you calculate the FFT with $N$ samples, then the FFT calculates the signal's spectrum at $N$ frequencies from $-f_s/2$ to $f_s/2-f_s/N$, inclusive. In Matlab notation, this would be written as:
freq_vector = (-N/2:N/2-1)./(f_s/N);

(Note that you have to shift the spectrum returned by the FFT operation to correspond to this vector; in Matlab, you would use fftshift.)