2
$\begingroup$

My professor mentioned that the order of a band-pass and a notch filter must always be even, when showing an example of designing a digital filter using the bilinear transformation.

Then he also mentions that the MATLAB code ellipord returns half the actual order, so I figured the two statements must be connected somehow. I can't ask him since it's currently 3 AM and I couldn't find anything alone as to why these two statements are true.

Any thoughts? Thank you!

$\endgroup$
3
$\begingroup$

I believe your thinking is correct. For bandpass filters, for each z-plane pole in the positive-frequency range there's a conjugate pole in the z-plane's negative-frequency range. So for bandpass filters there will all be an even number of total z-plane poles (two poles, four poles, six poles, etc.). When using MATLAB's ellipord command for bandpass filters that command returns the number of poles in the z-plane's positive-frequency range which is half the actual number of z-plane poles.

Practical bandpass filters will be even-ordered. Below Matt L points out that modifying an even-ordered filter’s transfer function by placing a z-plane zero at DC can make a bandpass filter odd-ordered, which is true. But placing a z-plane zero at DC so badly distorts the original even-ordered filter’s frequency response that the new odd-ordered filter becomes unusable.

$\endgroup$
7
  • $\begingroup$ Omg the man himself - what an honor! It's a lot clearer now; I wasn't putting two and two together but I wasn't aware of MATLAB doing that for the ellipord command. Thank you! Btw, I love your website. It's perfect for a quick reference or even refreshing my memory $\endgroup$
    – Kevin KZ
    Apr 25 at 16:21
  • $\begingroup$ @Kevin KZ. Thanks for your kind words. MATLAB’s ‘ellipord’ command uses a lowpass -to- bandpass “frequency transformation” algorithm whose reference is the book Theory and Application of Digital Signal Processing by Rabiner and Gold. (A VERY good, but out-of-print, DSP book.) Shockingly, MATLAB’s ellipord documentation does NOT tell you where in the 760 page book to look for more information!! I believe the algorithm they’re referring to is given as Transformation# 3 on the book's page 260. (I’ve added another paragraph to my “Answer” to your question.) Good Luck with your DSP studies Kevin. $\endgroup$ Apr 25 at 21:43
  • $\begingroup$ The claim in your last paragraph is wrong. You're overlooking the fact that a bandpass filter could have a zero at DC but none at Nyquist, or the other way around. So it's perfectly possible to have a bandpass filter with an odd filter order. $\endgroup$
    – Matt L.
    Apr 26 at 9:10
  • $\begingroup$ @Matt L. In the special case where infinite attenuation at DC is mandatory then, yes, you could place a z-plane zero at z = 0. $\endgroup$ Apr 26 at 17:22
  • $\begingroup$ So wouldn't it then be appropriate to modify the sentence "For a bandpass filter to have real-valued coefficients [...] the filter’s z-domain transfer function must be even-ordered", since it is clearly wrong? $\endgroup$
    – Matt L.
    Apr 26 at 17:25
6
$\begingroup$

In principle there is no reason why the filter order of a general bandpass or bandstop filter must be even. Such a restriction is a consequence of a specific design procedure. In classic IIR filter design (Butterworth, Chebyshev, Cauer) you start with an analog prototype lowpass filter. Bandpass or bandstop filters are then obtained by a frequency transformation. And it is this frequency transformation that doubles the order of the prototype lowpass filter, hence the even filter order for that specific design method. Note that the bilinear transform has nothing to do with that restriction on the filter order.

Of course, there are specific designs for which an odd filter order doesn't make much sense. E.g., for a notch filter (with a notch frequency greater than zero) you want exactly one zero at the notch frequency plus its mirror image at the negative notch frequency. So for each notch frequency you get two zeros, and, consequently, two poles.

$\endgroup$
1
  • $\begingroup$ I understand now. I thought he said it as an absolute way and I had never heard of such a principle before but like you said, it's a consequence of the design itself. Thank you! $\endgroup$
    – Kevin KZ
    Apr 25 at 16:23
3
$\begingroup$

Maybe that's a just a matter of semantics. You can certainly cascade an even order high pass with an odd order lowpass and you get something that's an odd order filter that sure looks like a bandpass.

%% odd order bandpass
fs = 44100;
fc = 1000;
[z,p,k] = butter(2,fc/sqrt(2)/fs*2,'high');
sos = zp2sos(z,p,k);
[z,p,k] = butter(3,fc*sqrt(2)/fs*2);
sos = [sos; zp2sos(z,p,k)];
nx = 8192;
f = logspace(log10(20),log10(20000),1000);
h = freqz(sos,f,fs);
semilogx(f,20*log10(abs(h)));
xlabel('Frequency in Hz'); ylabel('Level in dB'); title('odd order bandpass');
grid('on');
set(gca,'xlim',[f(1) f(end)]); set(gca,'ylim',[-60 3]);
$\endgroup$
5
  • 1
    $\begingroup$ The above code crashes when run using MATLAB. Is it OCTAVE code? $\endgroup$ Apr 25 at 10:32
  • $\begingroup$ that's interesting; good to know. Thanks $\endgroup$
    – Kevin KZ
    Apr 25 at 16:24
  • 1
    $\begingroup$ This is true. Strange looking filters exist. I vaguely remember something about an LC for an ECG (or EKG?), and which had different slopes. The code in Octave says: freqz: B must be a vector. $\endgroup$ Apr 25 at 22:28
  • $\begingroup$ @RichardLyons: sorry, this runs fine on my machine running ('9.8.0.1396136 (R2020a) Update 3'). I don't see anything remotely offensive in there. What line does it bomb on ? $\endgroup$
    – Hilmar
    Apr 26 at 11:50
  • 1
    $\begingroup$ @Hilmar. Hi. I'm running MATLAB 2019b. The command semilogx(f,20*log10(abs(h))); crashes because vectors 'f' and 'h' have different lengths. $\endgroup$ Apr 26 at 16:48

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.