3
$\begingroup$

Let's say sampling rate is $Fs = 44\mathtt{kHz}$, now I have $N = 2048$ samples, then I can get $N/2 + 1 = 1025$ frequencies.

I'm confused by Matlab's FFT documentation that says the frequencies are present at:

(Fs/2) * linspace(0, 1, N/2+1)

It is very probable that the real frequencies are not among the frequencies generated. What should we do to get the real frequencies?

$\endgroup$
2
  • $\begingroup$ What restrictions are present? It sounds like you're limited to sampling adaptively or collecting more samples. $\endgroup$
    – Scott
    Aug 11, 2014 at 5:37
  • $\begingroup$ The restriction is that we only have limited numbers of samples. How can we get the real frequency, is it OK to add series of 0 just to increase the sample number? $\endgroup$ Aug 11, 2014 at 6:32

3 Answers 3

6
$\begingroup$

Any measurement has a finite precision. You can't find real frequency exactly in general. You can evaluate it with necessary precision instead. In the case of FFT if the real frequency doesn't match FFT frequency grid exactly, power spectrum is spreading mostly among neighbouring frequency bins (among all bins in general, but most of it is focused in a few adjacent ones). Nevertheless you can estimate the real frequency by finding maximum of such a spectrum. Dealing with FFT you can improve the precision of frequency search by increasing the number of samples. If you can't, you should use another power spectrum estimation techniques but it's the separate question.

Hope this helps.

$\endgroup$
7
  • 1
    $\begingroup$ Let's say we press one key on piano which only lasts for 1/16 seconds. Then samples we have is Fs x 1/16. Our ear knows what key it is, just say D4 key (293HZ), However, based on (Fs/2)⋅linspace(0,1,N/2+1), frequency can not map to 293HZ, the range is like 260HZ, 310HZ, it skips 293HZ. $\endgroup$ Aug 11, 2014 at 6:28
  • $\begingroup$ With such an input neighbouring frequency bins are 288Hz (18th) and 304Hz (19th). So the most of energy will spread among these bins with maximum at 18th bin. You can say, let it be 288Hz and 5Hz error is neglectable. Or you can estimate frequency more precisely using all non-zero frequency bins and some kind of averaging (if the signal strength is low this approach won't work). Or you can try to increase signal duration. $\endgroup$
    – Serj
    Aug 11, 2014 at 7:25
  • 1
    $\begingroup$ About adding zeros: if you add zeros in the end of your sample sequence you can find more FFT points, but precision states the same. In such a case all FFT frequencies will grow in width (you'll see sinc function in the case of harmonic input). With this approach you can find maximum that is between 288Hz and 304Hz, but there will be no more sharp peak. You probably should try this method in MATLAB, may be it will work for you $\endgroup$
    – Serj
    Aug 11, 2014 at 7:41
  • 1
    $\begingroup$ Nitpick: energy smears over all frequency bins, ones that are closest are affected most. $\endgroup$
    – jojeck
    Aug 11, 2014 at 7:51
  • 1
    $\begingroup$ I can't provide you some math about this on a fly, but look here: dsp.stackexchange.com/questions/741/…, maybe it'll help. Also look at fine Doppler estimation topics (e.g. Richards "Fundamentals of radar signal processing", chap 5.3.4). If you are interesting in only few frequencies these methods may be better for your task (in the sense of computations required) $\endgroup$
    – Serj
    Aug 12, 2014 at 7:34
2
$\begingroup$

For computing a few frequency components the Goertzel algorithm is usually used. Note that the frequencies do not need to lie on a grid (as is the case with the FFT).

$\endgroup$
2
$\begingroup$

This is not an inherent disadvantage of the FFT. This is an inherent disadvantage more related to the limited length window or number of samples and any a-priori assumptions or analysis of the S/N ratio. In low noise, narrow-band "real" frequency peaks can be estimated between FFT result bins by interpolation. See: Number of FFT points required for a specific frequency resolution for an oversampled signal

$\endgroup$
2
  • $\begingroup$ From 1024 samples, human ear can recognise the frequency, but FFT can not choose out this frequency. No doubt ear is a very powerful filter. Basically, this disadvantage is limited by FFT theorem or computer computing ability? $\endgroup$ Aug 12, 2014 at 5:35
  • $\begingroup$ Neither. Instead by the length of the sample window and the S/N ratio around the desired frequency being estimated. $\endgroup$
    – hotpaw2
    Aug 12, 2014 at 7:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.