0
$\begingroup$

This question already has an answer here:

Say I'd like to bandpass filter a signal with corner frequencies 1 kHz and 2 kHz (i.e., passes signals between 1 kHz and 2 kHz and suppresses other frequencies) using software like MATLAB. Intuition tells me there's two ways to do this:

  1. Use filter design tools to create, say, a 10th order Butterworth filter. Use the filter command with the filter coefficients and input signal. This works, but the filter is nonideal (specifically, there will be some passband ripple, and the frequency cutoffs won't be immediate -- a signal at say, 2.1 kHz, will still be partially passed).
  2. Perform an FFT on the input signal. Set any FFT element corresponding to a frequency outside the 1 kHz-2 kHz range to zero. Inverse FFT the input signal. This will essentially be an ideal filter -- anything between 1kHz-2 kHz is passed with unity gain (no passband ripple), and anything outside 1 kHz-2 KHz is exactly zero (immediate cutoff).

Intuition tells me that #2 is better, because it's an ideal filter. I've learned that an ideal filter can't be built using analog components, but if a certain application is purely digital, why not use the ideal filter?

That being said, I've seen lots of code that uses tools like a nonideal 10th order Butterworth filter -- so what am I overlooking? What's the advantage of using a nonideal filter?

$\endgroup$

marked as duplicate by hotpaw2, Matt L., lennon310, jojek, Community Apr 6 '15 at 15:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    $\begingroup$ There are many similar questions on the website; for example: dsp.stackexchange.com/questions/16359/… or dsp.stackexchange.com/questions/6220/…. $\endgroup$ – MBaz Apr 3 '15 at 23:50
  • $\begingroup$ there is no passband ripple with a Butterworth prototype. no stopband ripple either. Butterworth is smooth as a baby-bottom. like $\omega$. and remember (regarding your #2), that FFT and iFFT do circular convolution and that the frequency response $H[k]$ has to correspond to a finite-length impulse response, h[n], an "FIR". i don't think your $H[k]$ does really. $\endgroup$ – robert bristow-johnson Apr 4 '15 at 2:57
  • 1
    $\begingroup$ The advantage of non-ideal filters is that they can be implemented. Ideal ones can't. This answer will help you understand why your #2 does not work as you expect it to. $\endgroup$ – Matt L. Apr 4 '15 at 17:49
0
$\begingroup$

Your assumption #2 is false. Zeroing bins does not produce an ideal filter with unity gain in the passband. Far from it if you look closely (between FFT bins).

$\endgroup$

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