I have a time varying discrete signal x(t) sampled at 5ms rate. I need to find the amplitude of the 20 Hz frequency component for each sample. What I do today is that for each sample I do a Short-time Fourier Transform of the data in a window around that sample. Then I read the amplitude for the 20 Hz frequency component off the amplitude spectrum. This seems to work fine, but it is slow.

How can I speed up this process? For instance I am only interested in the 20 Hz component. Is there some way I can avoid finding the complete amplitude spectrum (that is faster than FFT)?


As pichenettes already pointed out in a comment above, one approach is to use the Goertzel algorithm. However, it is a somewhat common misconception that in order to deduce the amplitude of various frequency bands in a signal, one must use Fourier-transform-based techniques. There are other methods that may be more appropriate to your application.

In your case, for example, you would do equally well by just creating any bandpass filter centered at 20 Hz and watching the amplitude of its output over time. The DFT (and by extension the Goertzel algorithm) can be viewed as just a bank of equally-spaced, critically-sampled bandpass filters. If you only need one output, then a DFT is overkill, and the Goertzel algorithm can be limiting, as you don't have much control over its frequency response about 20 Hz.

| improve this answer | |
  • $\begingroup$ Hi, I'm in the same situation as the asker, but I'm not sure how to use the filter, if I filter the signal with a very narrow bandpass, I'll get a sine wave, how do I get an amplitude? do I have to do an RMS of the filtered signal? $\endgroup$ – nraynaud May 8 '16 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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