# Advantage of using nonideal filter in purely digital application [duplicate]

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?

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

• 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. – robert bristow-johnson Apr 4 '15 at 2:57