butter
The design of the Butterworth filter.
| Library |
|
Syntax
Function call
-
b,a = butter(n,Wn,ftype)— designs a digital Butterworth filter: low-pass filter, high-pass filter, bandpass filter or notch filter, depending on the value of the argumentftypeand the number of elementsWn. The resulting designs of the bandpass and notch filters are of the following order2n.When designing IIR filters with a gear ratio up to `4`Numerical instability can be encountered. For more information about numerical problems affecting the formation of the transfer function, see Transfer functions and CTFs.
-
z,p,k = butter(___,out=3)— designs a digital Butterworth filter and returns its zeros, poles, and gain. This syntax can include any input arguments from the previous options. Argumentoutshows how many output arguments the function will return. If the argument isoutomitted, the function will calculate only for the two output arguments.
-
___ = butter(___,"s")— designs an analog Butterworth filter using any of the input or output arguments in the previous syntaxes.
-
B,A = butter(n,Wn,"ctf")— designs a digital Butterworth low-pass filter using cascaded transfer functions of the second order (Cascaded Transfer Functions, CTF). The function returns matrices containing the polynomial coefficients of the denominator and numerator of the filter transfer function, represented as a cascade of filter sections. This approach makes it possible to create IIR filters with improved numerical stability compared to single-section transfer functions.
Arguments
Input arguments
# n — filter order
+
an integer scalar
Details
The filter order, specified as an integer scalar, is less than or equal to 500. For bandpass and notch filters, the argument n represents half of the filter order.
| Data types |
|
# Wn is the cutoff frequency
+
scalar | two-element vector
Details
The cutoff frequency, specified as a scalar or a two-element vector. The cutoff frequency is the frequency at which the amplitude-frequency response of the filter is .
-
If
Wnis a scalar, then the functionbutterdesigns a low-pass or high-pass filter with a cutoff frequencyWn.If
Wn— two-element vector[w1,w2], wherew1 < w2, then the functionbutterdesigns a bandpass or notch filter with a lower cutoff frequencyw1and and the upper cutoff frequencyw2. -
For digital filters, the cutoff frequencies should be in the range of
0before1, where1corresponds to the Nyquist frequency — half of the sampling frequency or rad/countdown.For analog filters, the cutoff frequencies must be expressed in radians per second and can take any positive value.
| Data types |
|
# ftype — filter type
+
"low" | "bandpass" | "high" | "stop"
Details
The type of filter set using one of the following methods:
-
"low"defines a low-pass filter with a cutoff frequencyWn. Meaning"low"is the default value for a scalarWn. -
"high"defines a high-pass filter with a cutoff frequencyWn. -
"bandpass"defines a bandpass filter of the order2nifWn— a two-element vector. Meaning"bandpass"it is the default value ifWnIt consists of two elements. -
"stop"defines the notch filter of the order2nifWn— a two-element vector.
Name-value input arguments
# out — number of output arguments
+
a positive integer scalar
Details
The number of output arguments specified as a positive integer. If the argument is out 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 as follows:
-
for digital filters;
-
for analog filters.
| Data types |
|
# z,p,k — zeros, poles, and gain
+
column vectors, scalar
Details
Zeros, poles, and filter gain, 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 as follows:
-
for digital filters;
-
for analog filters.
| Data types |
|
# A,B,C,D — representation 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 equally , B equally , C equally , and D equally .
Matrices in the state space relate the state vector , the input signal and the output signal by using one of the following systems of equations.
-
For digital filters:
-
For analog filters:
| Data types |
|
# B,A are the coefficients of the cascade transfer function
+
vector string | the matrix
Details
Coefficients of the Cascaded transfer Function (CTF), returned as a row vector or matrix. B and A — the coefficients of the numerator and denominator of the cascade transfer function, respectively.
Sizes B and A: on and on accordingly. The function returns the first column of the matrix A how 1, thus, A(1)=1 when A — vector is a string.
-
L— the number of filter sections. -
m— the order of the numerators of the filter. -
n— the order of the denominators of the filter.
Function butter returns the coefficients of the cascade transfer function with the following order parameters:
-
for low- and high-pass filters;
-
for band-pass and notch filters.
To set up the calculation of the cascade transfer function coefficient, for example, to set a different order in the coefficients of the cascade transfer function or to adjust the gain scaling, specify the return z,p,k and then use the function zp2ctf to get B,A.
|
For more information about the cascade transfer function format and coefficient matrices, see Return of digital filters in CTF format.
# gS is the total gain of the system
+
the real scalar
Details
The total gain of the system, returned as a real scalar.
-
If specified, you need to return
gS, functionbutternormalizes the coefficients of the numerator so that the first columnBwas equal to1, and returns the total gain of the system ingS. -
If not specified, what needs to be returned
gS, functionbutterdistributes the system gain evenly across all sections of the system using the functionscaleFilterSections.
Additional Info
Cascading transfer functions
Details
Splitting a digital IIR filter into cascaded sections increases its numerical stability and reduces its susceptibility to coefficient quantization errors. Cascade form of the transfer function in terms of transfer functions it has the form
Return of digital filters in CTF format
Details
Specify the arguments B and A to return the filter coefficients. You can also specify gS to return the overall gain of the system. By specifying these output arguments, you can design digital filters in CTF format for signal analysis, visualization, and filtering.
coeffects of the filter
If you specify the return of the numerator and denominator coefficients in CTF format, -lowercase matrices and they are returned as
thus, the total transfer function of the filter is
where
The following functions can be used to visualize and analyze filters in CTF format. Characteristics in the time domain — impzlength and impz. Characteristics in the frequency domain — freqz, grpdelay, phasedelay and phasez. Filter Research — islinphase, ismaxphase and isstable.
|
coeffects and amplification
You can specify that you want to return the coefficients and the total gain of the system using a triplet of output arguments. B,A,gS. In this case, the coefficients of the numerator are normalized, returning the matrices of the filter coefficients and the gain factor in the form
so the transfer function has the form
This transfer function is equivalent to the function defined in section Filter coefficients, where
Transfer functions and CTFs
Details
The numerical instability of the syntax of transfer functions
In general, cascading transfer functions (syntaxes) should be used to design digital IIR filters. "ctf"). When designing a filter using transfer functions (any of the syntaxes b,a), numerical instabilities may occur. These instabilities are caused by rounding errors and can even occur in orders of magnitude n up to 4.
Algorithms
Butterworth filters have the most flat amplitude-frequency response (frequency response) in the passband and are monotonic in general. This smoothness is achieved by reducing the steepness of the drop. Elliptical filters and Chebyshev filters usually provide a steeper drop for a given filter order.
Function butter uses a five-step algorithm:
-
It finds the poles, zeros, and gain of a prototype analog low-pass filter.
-
It converts poles, zeros, and gain into a state space form.
-
If necessary, it uses a state space transformation to convert a low-pass filter into a band-pass, high-pass, or notch filter with the required frequency limits.
-
A bilinear function is used to design digital filters. to convert an analog filter to a digital one by means of a bilinear conversion with a preliminary frequency distortion. Fine frequency tuning allows analog and digital filters to have the same frequency response amplitude
Wnorw1andw2. -
If necessary, it transforms the state space filter back into its transfer function or gain zero pole form.