cheby2
Calculation of Chebyshev filter type II.
| Library |
|
Syntax
Function call
-
b, a = cheby2(n, Rs, Ws)— designs a Chebyshev type II digital low-pass filtern`of the 1st order with a normalized boundary frequency of the delay band `Wsand attenuation in the delay bandRsdB from the peak bandwidth value. Functioncheby2returns the coefficients of the numerator and denominator of the filter transfer function.
-
A, B, C, D = cheby2(_; nout=4)— designs a Chebyshev type II digital filter and returns matrices that define its representation in the state space.
-
_ = cheby2(_, "s"; nout)— designs an analog Chebyshev type II filter using any of the input or output arguments in the previous syntaxes. Argumentnoutshows how many output arguments the function will return. If the argument isnoutomitted, the function will calculate only for the two output arguments.
Arguments
Input arguments
# n — filter order
+
scalar
Details
The filter order, specified as an integer scalar, is less than or equal to 500. For band-pass and notch filters n represents half of the filter order.
| Типы данных |
|
# Rs — attenuation in the delay band in dB
+
positive scalar
Details
The attenuation in the delay band is relative to the peak value in the passband, set as a positive scalar in dB.
If the value is expressed in linear units, you can convert it to dB using the formula Rs .
| Типы данных |
|
#
Ws —
the limit frequency
of the delay band
scalar | two-element vector
Details
The boundary frequency of the delay band, specified as a scalar or a two-element vector. The boundary frequency of the delay band is the frequency at which the amplitude-frequency response (frequency response) of the filter is equal to −Rs in dB. Large delay band attenuation values Rs they lead to increased bandwidth.
-
If
Ws— a scalar, thencheby2designs a low-pass or high-pass filter with a cut-off frequencyWs.If
Ws— two-element vector[w1 w2], wherew1 < w2Thencheby2designs a bandpass or notch filter with a lower cut-off frequencyw1and the upper boundary frequencyw2. -
For digital filters, the frequency limits of the delay band should be in the range of
0before1, where1corresponds to the Nyquist frequency — half of the sampling frequency or rad/countdown.For analog filters, the boundary frequencies of the delay band must be expressed in rad/s and can take any positive value.
| Типы данных |
|
# ftype — filter type
+
"low" | "bandpass" | "high" | "stop"
Details
The filter type specified as:
-
"low"— low-pass filter with a boundary frequency of the delay bandWs. This value is used by default for scalarWs; -
"high"— high-pass filter with a boundary frequency of the delay bandWs; -
"bandpass"— bandpass filter2nof the order ifWs— a two-element vector. This value is used by default whenWsset as a two-element vector; -
"stop"— notch (blocking) filter2nof the order ifWs— a two-element vector.
| Типы данных |
|
Name-value input arguments
# nout — number of output arguments
+
2 (by default) | 3 | 4
Details
The number of output arguments, set as 2, 3 or 4. If the argument is nout not specified, the function returns two output arguments by default.
Output arguments
# b, a are the coefficients of the transfer function
+
string vectors
Details
Coefficients of the filter transfer function returned as row vectors. With the specified filter order n the function returns b and a with r by counting where r = n + 1 for low and high pass filters and r = 2 * n + 1 for band-pass and notch filters.
The transfer function is expressed in terms of and :
-
for digital filters
-
for analog filters
| Типы данных |
|
# z, p, k — zeros, poles, and gain
+
column vectors and scalar
Details
The zeros, poles, and gain of the filter, returned as two vectors-columns and a scalar. With the specified filter order n the function returns z and p with r by counting where r = n for low and high pass filters and r = 2 * n for band-pass and notch filters.
The transfer function is expressed in terms of , and :
-
for digital filters
-
for analog filters
| Типы данных |
|
# A, B, C, D — representation of the filter in the state space
+
matrices
Details
The representation of the filter in the state space, returned as matrices. If r = n for low and high pass filters and r = 2n for band-pass and notch filters, then A This is the matrix r on r, B the matrix r on 1, C the matrix 1 on r, and D — 1 on 1.
The state space matrices relate the state vector , entrance and the exit by means of systems of equations:
-
for digital filters
-
for analog filters
| Типы данных |
|
Examples
Chebyshev type II low-pass filter
Details
Let’s design a Chebyshev type II low-pass filter 6-th order with attenuation in the barrier strip 50 dB and bandwidth cutoff frequency 300 Hz, which corresponds to 0.6π rad/count for data sampled with frequency 1000 Hz. Let’s plot the amplitude-frequency and phase characteristics. We use it to filter a random signal with a frequency 1000 counts.
import EngeeDSP.Functions: cheby2, freqz, randn, filter
fc = 300
fs = 1000
b, a = cheby2(6,50,fc/(fs/2))
freqz(b,a,out=:plot)

dataIn = randn(1000,1)
dataOut = filter(b,a,dataIn)
Chebyshev type II barrier filter
Details
Let’s design a type II Chebyshev barrier filter 6-th order with normalized boundary frequencies 0.2π and 0.6π rad/countdown and attenuation in the boom lane 50 dB. Let’s plot the amplitude-frequency and phase characteristics. We use it to filter a random signal.
import EngeeDSP.Functions: cheby2, freqz, randn, filter
b,a = cheby2(6,50,[0.2 0.6],"stop")
freqz(b,a,out=:plot)

dataIn = randn(1000,1)
dataOut = filter(b,a,dataIn)
Chebyshev type II high-pass filter
Details
Let’s design a Chebyshev type II high-pass filter 9-th order with bandwidth cutoff frequency 300 Hz, which is for data sampled with frequency 1000 Hz, corresponds to 0.6π rad/countdown. Setting the attenuation in the barrier strip 20 dB. Convert the zeros, poles, and gain into second-order sections. Let’s plot the amplitude-frequency and phase characteristics.
import EngeeDSP.Functions: cheby2, zp2sos
z,p,k = cheby2(9,20,300/500,"high"; nout=3)
sos = zp2sos(z,p,k)
freqz(sos,out=:plot)

Chebyshev type II bandpass filter
Details
Let’s design a Chebyshev type II bandpass filter 10-th order with lower bandwidth 500 Hz and upper bandwidth 560 Hz. Set the attenuation in the barrier strip 40 dB and sampling rate 1500 Hz. We use a representation in the state space. We transform the representation in the state space into the form of sections of the second order. Let’s plot the amplitude-frequency and phase characteristics.
import EngeeDSP.Functions: cheby2, ss2sos
fs = 1500
A,B,C,D = cheby2(10,40,[500 560]/(fs/2); nout=4)
sos = ss2sos(A,B,C,D)[1]
freqz(sos,out=:plot)

Algorithms
Chebyshev type II filters are monotonous in the passband and have uniform pulsation in the delay band. Type II filters do not have as fast a drop in performance as type I filters, but they do not have ripples in the bandwidth.
Chebyshev filter type II cheby2 uses a five-step algorithm:
-
Finds the poles, zeros, and gain of the analog low-pass prototype.
-
Converts poles, zeros, and gain into a state space.
-
If necessary, it uses a state-space transformation to convert a low-pass filter into a high-pass filter, bandpass filter, or notch filter with the required frequency constraints.
-
To design digital filters, it converts an analog filter to a digital one by means of a bilinear frequency pre-distortion conversion. Fine frequency tuning allows analog and digital filters to have the same frequency response amplitude
Wsorw1andw2. -
If necessary, it converts the state space filter back into a transfer function or a zero-pole-gain form.