Last chance! 50% off unlimited learning
Sale ends in
Compute the minimum filter order of a Butterworth filter with the desired response characteristics.
buttord(Wp, Ws, Rp, Rs, plane = c("z", "s"))
pass-band and stop-band edges. For a low-pass or high-pass
filter, Wp
and Ws
are scalars. For a band-pass or
band-rejection filter, both are vectors of length 2. For a low-pass filter,
Wp < Ws
. For a high-pass filter, Ws > Wp
. For a band-pass
(Ws[1] < Wp[1] < Wp[2] < Ws[2])
or band-reject (Wp[1] < Ws[1]
< Ws[2] < Wp[2])
filter design, Wp
gives the edges of the pass
band, and Ws
gives the edges of the stop band. For digital filters,
frequencies are normalized to [0, 1], corresponding to the range [0, fs/2].
In case of an analog filter, all frequencies are specified in radians per
second.
allowable decibels of ripple in the pass band.
minimum attenuation in the stop band in dB.
"z" for a digital filter or "s" for an analog filter.
A list of class FilterSpecs
with the following list
elements:
filter order
cutoff frequency
filter type, normally one of "low", "high", "stop", or "pass".
Deriving the order and cutoff is based on:
2 (2N) (-R / 10) |H(W)| = 1/[1 + (W / Wc) ] = 10
With some algebra, you can solve simultaneously for Wc
and N
given Ws
, Rs
and Wp,Rp. Rounding N to the next greater integer,
one can recalculate the allowable range for Wc
(filter characteristic
touching the pass band edge or the stop band edge).
For other types of filter, before making the above calculation, the
requirements must be transformed to lowpass requirements. After the
calculation, Wc
must be transformed back to the original filter type.
# NOT RUN {
## low-pass 30 Hz filter
fs <- 128
butspec <- buttord(30/(fs/2), 40/(fs/2), 0.5, 40)
but <- butter(butspec)
freqz(but, fs = fs)
# }
Run the code above in your browser using DataLab