Signal Processing Toolbox

Classical IIR Filter Design Using Analog Prototyping

The principal IIR digital filter design technique this toolbox provides is based on the conversion of classical lowpass analog filters to their digital equivalents. The following sections describe how to design filters and summarize the characteristics of the supported filter types. See Special Topics in IIR Filter Design for detailed steps on the filter design process.

Complete Classical IIR Filter Design

You can easily create a filter of any order with a lowpass, highpass, bandpass, or bandstop configuration using the filter design functions.

 Filter Type Design Function Bessel (analog only) `[b,a] = besself(n,Wn,options)``[z,p,k] = besself(n,Wn,options)``[A,B,C,D] = besself(n,Wn,options)` Butterworth `[b,a] = butter(n,Wn,options)``[z,p,k] = butter(n,Wn,options)``[A,B,C,D] = butter(n,Wn,options)` Chebyshev Type I `[b,a] = cheby1(n,Rp,Wn,options)``[z,p,k] = cheby1(n,Rp,Wn,options)``[A,B,C,D] = cheby1(n,Rp,Wn,options)` Chebyshev Type II `[b,a] = cheby2(n,Rs,Wn,options)``[z,p,k] = cheby2(n,Rs,Wn,options)``[A,B,C,D] = cheby2(n,Rs,Wn,options)` Elliptic `[b,a] = ellip(n,Rp,Rs,Wn,options)``[z,p,k] = ellip(n,Rp,Rs,Wn,options)``[A,B,C,D] = ellip(n,Rp,Rs,Wn,options)`

By default, each of these functions returns a lowpass filter; you need only specify the desired cutoff frequency `Wn` in normalized frequency (Nyquist frequency `=` 1 Hz). For a highpass filter, append the string `'high'` to the function's parameter list. For a bandpass or bandstop filter, specify `Wn` as a two-element vector containing the passband edge frequencies, appending the string `'stop'` for the bandstop configuration.

Here are some example digital filters:

• ```[b,a] = butter(5,0.4);            % Lowpass Butterworth
[b,a] = cheby1(4,1,[0.4 0.7]);    % Bandpass Chebyshev Type I
[b,a] = cheby2(6,60,0.8,'high');  % Highpass Chebyshev Type II
[b,a] = ellip(3,1,60,[0.4 0.7],'stop');% Bandstop elliptic
```

To design an analog filter, perhaps for simulation, use a trailing `'s'` and specify cutoff frequencies in rad/s:

• ```[b,a] = butter(5,.4,'s'); % Analog Butterworth filter
```

All filter design functions return a filter in the transfer function, zero-pole-gain, or state-space linear system model representation, depending on how many output arguments are present.

 Note    All classical IIR lowpass filters are ill-conditioned for extremely low cut-off frequencies. Therefore, instead of designing a lowpass IIR filter with a very narrow passband, it can be better to design a wider passband and decimate the input signal.

Designing IIR Filters to Frequency Domain Specifications

This toolbox provides order selection functions that calculate the minimum filter order that meets a given set of requirements.

 Filter Type Order Estimation Function Butterworth `[n,Wn] = buttord(Wp,Ws,Rp,Rs)` Chebyshev Type I `[n,Wn] = cheb1ord(Wp, Ws, Rp, Rs)` Chebyshev Type II `[n,Wn] = cheb2ord(Wp, Ws, Rp, Rs)` Elliptic `[n,Wn] = ellipord(Wp, Ws, Rp, Rs)`

These are useful in conjunction with the filter design functions. Suppose you want a bandpass filter with a passband from 1000 to 2000 Hz, stopbands starting 500 Hz away on either side, a 10 kHz sampling frequency, at most 1 dB of passband ripple, and at least 60 dB of stopband attenuation. You can meet these specifications by using the `butter` function as follows.

• ```[n,Wn] = buttord([1000 2000]/5000,[500 2500]/5000,1,60)
n =
12
Wn =
0.1951    0.4080
[b,a] = butter(n,Wn);
```

An elliptic filter that meets the same requirements is given by

• ```[n,Wn] = ellipord([1000 2000]/5000,[500 2500]/5000,1,60)
n =
5
Wn =
0.2000    0.4000
[b,a] = ellip(n,1,60,Wn);
```

These functions also work with the other standard band configurations, as well as for analog filters; see Function Reference for details.

 IIR Filter Design Comparison of Classical IIR Filter Types