Generates the lowest filter order and the corresponding corner frequencies of a Butterworth digital or analog filter meeting a given set of filter specifications. The filter type (high-pass, low-pass, band- pass, or band-stop) is specified by the relative values of the arguments. |
||
Syntax |
Order, Wn = ButterOrd(Wp, Ws, Rp, Rs, Type) |
|
Arguments |
Name |
Description |
Wp |
Passband corner frequency normalized by the Nyquist frequency. Ranges between 0 and 1 in the digital case and positive in the analog case. For low-pass and high-pass filters, this is a scalar. For band-pass and band-stop, it's a two element vector, with the second element being larger of the two. |
|
Ws |
Stopband corner frequency normalized by the Nyquist frequency. Ranges between 0 and 1 in the digital case and positive in the analog case. For low-pass and high-pass filters, this is a scalar. For band-pass and band-stop, it's a two element vector, with the second element being larger of the two. |
|
Rp |
Maximum permissible passband attenuation (loss) in dB. Must be a negative scalar. |
|
Rs |
Minimum permissible stopband attenuation (loss) in dB, relative to the maximum passband magnitude. Must be a negative scalar and greater than Rp in magnitude. |
|
Type (optional) |
The digital/analog flag. For analog, set to ‘s.’ For digital, set to ‘z’ (default). |
|
Outputs |
Name |
Description |
Order |
The minimum filter order that meets the above specifications. |
|
Wn |
Alternate passband corner frequencies that will meet the above specifications. |
|
Example 1 |
A low-pass Butterworth filter design with a passband of 0-150 Hz, with attenuation of no more than 3 dB, and a minimum of 20 dB attenuation in the stopband defined from 250 Hz to the Nyquist frequency. Data sampling frequency is 1000 Hz: |
|
Syntax |
||
n, Wn = ButterOrd(150/500,250/500,-3,-20) |
||
Result |
||
n = 4 Wn = 0.33 |
||
Example 2 |
A band-pass Butterworth filter with a passband of 150-250 Hz, with maximum attenuation of no more than 3 dB and a minimum of 20 dB attenuation in stopbands that have corner frequencies 50 Hz away from the passband corners. Data sampling frequency is 1000 Hz: |
|
Syntax |
||
n, Wn = ButterOrd([150/500 250/500],[100/500 300/500],-3,-20) |
||
Result |
||
n = 4 Wn = 0.29 0.52 |
||
Comments |
The Nyquist frequency is half the sampling frequency. All frequency arguments are to be normalized with this. The guidelines for specifying different filter types are listed below: |
Type |
Stopband and Passband Conditions |
Stopband |
Passband |
Lowpass |
Wp < Ws where both are scalars |
(Ws, 1) |
(0, Wp) |
Highpass |
Wp > Ws where both are scalars |
(0, Ws) |
(Wp, 1) |
Bandpass |
Ws(1) < Wp(1) < Wp(2) < Ws(2) |
(0, Ws(1)) and (Ws(2), 1) |
(Wp(1), Wp(2)) |
Bandstop |
Wp(1) < Ws(1) < Ws(2) < Wp(2) |
(Ws(1), Ws(2)) |
(0, Wp(1)) and (Ws(2), 1) |
See Also: |