Signal Processing Toolbox | Help Desk |
buttord
Butterworth filter order selection.
[n,Wn] = buttord(Wp,Ws,Rp,Rs) [n,Wn] = buttord(Wp,Ws,Rp,Rs,'s')
buttord
selects the minimum order digital or analog Butterworth filter required to meet a set of filter design specifications:[n,Wn] = buttord(Wp,Ws,Rp,Rs)
returns the order n
of the lowest order digital Butterworth filter that loses no more than Rp
dB in the passband and has at least Rs
dB of attenuation in the stopband. The passband runs from 0 to Wp
and the stopband runs from Ws
to 1, the Nyquist frequency. buttord
also returns Wn
, the Butterworth cutoff frequency that allows butter
to achieve the given specifications (the "3 dB" frequency).
Use buttord
for highpass, bandpass, and bandstop filters. For highpass filters, Wp
is greater than Ws
. For bandpass and bandstop filters, Wp
and Ws
are two-element vectors that specify the corner frequencies at both edges of the filter, lower frequency edge first. For the band filters, buttord
returns Wn
as a two-element row vector for input to butter
.
If filter specifications call for a bandpass or bandstop filter with unequal ripple in each of the passbands or stopbands, design the filter as separate lowpass and highpass sections and cascade the two filters together.
[n,Wn] = buttord(Wp,Ws,Rp,Rs,'s')
finds the minimum order n
and cutoff frequencies Wn
for an analog filter. In this case the frequencies in Wp
and Ws
are in radians per second and may be greater than 1.
Use buttord
for highpass, bandpass, and bandstop filters, as described under "Digital Domain."
For 1000 Hz data, design a lowpass filter with less than 3 dB of attenuation from 0 to 100 Hz, and attenuation at least 15 dB from 150 Hz to the Nyquist frequency. Plot the filter's frequency response:
Wp = 100/500; Ws = 150/500; [n,Wn] = buttord(Wp,Ws,3,15) n = 4 Wn = 0.2042 [b,a] = butter(n,Wn); freqz(b,a,512,1000)Next design a bandpass filter with passband of 100 Hz to 200 Hz, less than 3 dB of attenuation at the passband corners, and attenuation down 30 dB by 50 Hz out on both sides of the passband:
![]()
Wp = [100 200]/500; Ws = [50 250]/500; Rp = 3; Rs = 30; [n,Wn] = buttord(Wp,Ws,Rp,Rs); [b,a] = butter(n,Wn); freqz(b,a,128,1000)
![]()
buttord
's order prediction formula is described in [1]. It operates in the analog domain for both analog and digital cases. For the digital case, it converts the frequency parameters to the s-domain before estimating the order and natural frequency, then converts back to the z-domain.
buttord
initially develops a lowpass filter prototype by transforming the passband frequencies of the desired filter to 1 rad/sec (for low- and highpass filters) and to -1 and 1 rad/sec (for bandpass and bandstop filters). It then computes the minimum order required for a lowpass filter to meet the stopband specification.