butter | R Documentation |
Compute the transfer function coefficients of a Butterworth filter.
butter(n, ...)
## S3 method for class 'FilterSpecs'
butter(n, ...)
## Default S3 method:
butter(
n,
w,
type = c("low", "high", "stop", "pass"),
plane = c("z", "s"),
output = c("Arma", "Zpg", "Sos"),
...
)
n |
filter order. |
... |
additional arguments passed to butter, overriding those given by
|
w |
critical frequencies of the filter. |
type |
filter type, one of |
plane |
"z" for a digital filter or "s" for an analog filter. |
output |
Type of output, one of:
Default is |
Butterworth filters have a magnitude response that is maximally flat in the passband and monotonic overall. This smoothness comes at the price of decreased rolloff steepness. Elliptic and Chebyshev filters generally provide steeper rolloff for a given filter order.
Because butter is generic, it can be extended to accept other inputs, using
buttord
to generate filter criteria for example.
Depending on the value of the output
parameter, a list of
class Arma
, Zpg
, or Sos
containing the filter coefficients
Paul Kienzle, pkienzle@users.sf.net,
Doug Stewart, dastew@sympatico.ca,
Alexander Klein, alexander.klein@math.uni-giessen.de,
John W. Eaton.
Conversion to R by Tom Short,
adapted by Geert van Boxtel G.J.M.vanBoxtel@gmail.com.
https://en.wikipedia.org/wiki/Butterworth_filter
Arma
, Zpg
, Sos
,
filter
, cheby1
, ellip
,
buttord
.
## 50 Hz notch filter
fs <- 256
bf <- butter(4, c(48, 52) / (fs / 2), "stop")
freqz(bf, fs = fs)
## EEG alpha rhythm (8 - 12 Hz) bandpass filter
fs <- 128
fpass <- c(8, 12)
wpass <- fpass / (fs / 2)
but <- butter(5, wpass, "pass")
freqz(but, fs = fs)
## filter to remove vocals from songs, 25 dB attenuation in stop band
## (not optimal with a Butterworth filter)
fs <- 44100
specs <- buttord(230/(fs/2), 450/(fs/2), 1, 25)
bf <- butter(specs)
freqz(bf, fs = fs)
zplane(bf)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.