buttord {gsignal} | R Documentation |
Butterworth filter order and cutoff frequency
Description
Compute the minimum filter order of a Butterworth filter with the desired response characteristics.
Usage
buttord(Wp, Ws, Rp, Rs, plane = c("z", "s"))
Arguments
Wp , Ws |
pass-band and stop-band edges. For a low-pass or high-pass
filter, |
Rp |
allowable decibels of ripple in the pass band. |
Rs |
minimum attenuation in the stop band in dB. |
plane |
"z" for a digital filter or "s" for an analog filter. |
Details
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.
Value
A list of class FilterSpecs
with the following list
elements:
- n
filter order
- Wc
cutoff frequency
- type
filter type, normally one of "low", "high", "stop", or "pass".
Author(s)
Paul Kienzle,
adapted by Charles Praplan.
Conversion to R by Tom Short,
adapted by Geert van Boxtel, G.J.M.vanBoxtel@gmail.com.
See Also
Examples
## 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)