# Using FFT to extract a specific frequency range in Matlab?

I have a signal and from that I want to extract a specific frequency range, e.g. 10Hz to 15Hz. Now I heard that I should use Fast Fourier Transformation.

I'm going to do that in Matlab, but I have no idea where to start. Is there any good example how I can do this by passing the original signal and the frequency band as parameter?

• Do you want to build a bandpass filter that attenuates everything but the specified frequency range or do you intend to just analyze a certain band? – Deve Aug 22 '13 at 17:15
• I want to analyze a certain band. – RoflcoptrException Aug 22 '13 at 17:16
• dsp.stackexchange.com/questions/9251/… – niaren Aug 22 '13 at 20:12

To analyze a certain frequency band, you first have to know the sampling frequency $f_\mathrm{S}$ that has been used to acquire your signal $x$. To compute the discrete Fourier transform (DFT) in Matlab:
y = fft(x);
The output of Matlab's FFT function has length $N$ and begins with frequency 0, $N$ beeing the length of $x$. The frequency range you're looking for therefore lies in the index range $$N\frac{f_1}{f_\mathrm{S}} + 1\ldots N\frac{f_2}{f_\mathrm{S}} +1$$ Where $f_1$ is the lower and $f_2$ is the upper limit of your frequency range and $f_1 \leq f_2 \leq f_\mathrm{S}/2$ must hold. The addition of 1 accounts for Matlab indices beginning at 1, not at 0. Also note that in general the above expressions are non-integer numbers.