I'm currently using MATLAB's fdatool for filter design. Using that tool, I can easily design different kind of filters. For example, let's take a band-pass FIR filter with 10-40 Hz passband, and 5-10 Hz and 40-45 Hz transition bands. Usually, I design the filter with the selection "least-squares", which, if I understand correctly, uses the aforementioned method to find the best impulse response according to filter spesifications. To actually filter the signal, I use the command filtfilt, which does zero-phase FIR filtering.

Now, an alternative way to implement the filter would be to take the FFT of my signal, set frequencies outside the range 10-40 Hz as zeros, and then take the IDFT.

Is there any practical/theoretical difference between these two approaches? Will the frequency responses (magnitude and phase) be the same?


Filtering can be done in the frequency domain which is actually a very efficient technique (and it can very well be, that Matlab does this internally). However, for very long signals it's not as straight-forward as "taking the FFT and applying a frequency response". You can read up on overlap-add filtering which is a possibility to filter in frequency domain. However, this is mainly done because it can be faster.

However, this question is independent from filter design which is a completely different thing. Every FIR filter has a corresponding frequency response and it does not matter whether you convolve in time domain or apply the frequency response in frequency domain. So your approach becomes a question of filter design and the consequences it has.

Just setting unwanted frequencies to zero might completely eliminate those frequencies but it usually comes at the price of a significant ringing in the time domain which is usually unwanted (Wikipedia on ringing). So in fact, what you are proposing is just one way to design a filter and frankly not a good one in most cases.

By allowing a transition band in which the frequency response can gradually go from passband to stopband, degrees of freedom are gained that can be used to improve other properties of the resulting filter (for example eliminate the ringing or obtain a shorter impulse response). That's why Matlab implements so many different filter types, they all have different properties and selecting the most suited one is actually part of designing your signal processing system.

This topic is actually quite complicated and I suggest to read up on filter design. Whole books can be filled with this.

  • $\begingroup$ As a note, MATLAB provides the fftfilt function to apply an arbitrary FIR filter using fast (FFT-based) convolution. The standard filter command uses a direct-form II transposed structure, if I recall correctly. $\endgroup$ – Jason R Jul 25 '13 at 15:30

Regarding your idea of doing an FFT, zeroing out the undesired frequency components, and then doing an inverse FFT.

As a practical matter, this would require an impractical amount of computing for most applications. A real time signal could extend for more than a million samples. Very few applications could afford to do two ffts on this much data.

Aside from this however, there is an important aspect to filtering that you need to understand. Zeroing out frequency components is essentially the same as implementing a brick wall filter. Brick wall filters may sound great, but that is only because you don't understand the effects these filters have on the signal.

Brick wall filters can render a signal useless. For example, filtering a square wave with a brick wall low pass will introduce severe ringing into the square wave. About the only good use for brick wall filters (or zeroing out frequency components), would be to filter the noise out of a sine wave.

The key to filter design is to know both what you want to remove from the signal, and also knowing what you need to preserve in the signal. Preserving the signal's integrity is paramount; otherwise you might as well discard it completely.

The best way to gain an understanding of the detrimental effects of brick wall filters is to run your signal through a 15 pole elliptic, or something similar. There are some free FIR and IIR filter design programs at http://www.iowahills.com that make it quite easy to do this.

Unless you are working with some incredibly simple signals, it isn't likely that you will be able to tolerate brick wall filters, or equivalently, zeroing out frequency components.


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