Compute the transfer function coefficients of a Chebyshev Type II filter.
cheby2(n,...)## S3 method for class 'FilterSpecs'cheby2(n,...)## Default S3 method:cheby2( n, Rs, w, type = c("low","high","stop","pass"), plane = c("z","s"), output = c("Arma","Zpg","Sos"),...)
Arguments
n: filter order.
...: additional arguments passed to cheby1, overriding those given by n of class FilterSpecs.
Rs: dB of stopband ripple.
w: critical frequencies of the filter. w must be a scalar for low-pass and high-pass filters, and w must be a two-element vector c(low, high) specifying the lower and upper bands in radians/second. For digital filters, W must be between 0 and 1 where 1 is the Nyquist frequency.
type: filter type, one of "low", "high", "stop", or "pass".
plane: "z" for a digital filter or "s" for an analog filter.
output: Type of output, one of:
"Arma": Autoregressive-Moving average (aka numerator/denominator, aka b/a)
"Zpg": Zero-pole-gain format
"Sos": Second-order sections
Default is "Arma" compatibility with the 'signal' package and the 'Matlab' and 'Octave' equivalents, but "Sos" should be preferred for general-purpose filtering because of numeric stability.
Returns
Depending on the value of the output parameter, a list of class Arma, Zpg, or Sos
containing the filter coefficients
Details
Chebyshev filters are analog or digital filters having a steeper roll-off than Butterworth filters, and have passband ripple (type I) or stopband ripple (type II).
Because cheby2 is generic, it can be extended to accept other inputs, using cheb2ord to generate filter criteria for example.
Examples
## compare the frequency responses of 5th-order## Butterworth and Chebyshev filters.bf <- butter(5,0.1)cf <- cheby2(5,20,0.1)bfr <- freqz(bf)cfr <- freqz(cf)plot(bfr$w / pi,20* log10(abs(bfr$h)), type ="l", ylim = c(-40,0), xlim = c(0,.5), xlab ="Frequency", ylab = c("dB"))lines(cfr$w / pi,20* log10(abs(cfr$h)), col ="red")# compare type I and type II Chebyshev filters.c1fr <- freqz(cheby1(5,.5,0.5))c2fr <- freqz(cheby2(5,20,0.5))plot(c1fr$w / pi, abs(c1fr$h), type ="l", ylim = c(0,1.1), xlab ="Frequency", ylab = c("Magnitude"))lines(c2fr$w / pi, abs(c2fr$h), col ="red")