# 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
Commented Aug 22, 2013 at 17:15
• I want to analyze a certain band. Commented Aug 22, 2013 at 17:16
• dsp.stackexchange.com/questions/9251/… Commented Aug 22, 2013 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.

• Ok I see, but somehow I want the range I'm looking for for every data point. If I understood you correctly y has then only 1 datapoint in each bin for my signal. Commented Aug 22, 2013 at 17:39
• I assumed your signal was a time series, isn't it?
– Deve
Commented Aug 22, 2013 at 17:42
• Hmm let me make an example. I have sample my signal at 500Hz. So if I pass a 1 second sample of this signal as x to the fft function, then I get back only one value for my frequency range, but I want to have also 500. Commented Aug 22, 2013 at 17:45
• That's impossible. Additionaly, the frequency range from 10 to 15 Hz corresponds to 6 samples in the FFT output in your example.
– Deve
Commented Aug 22, 2013 at 19:06