y = filtfilt(b, a, x) — performs zero-phase digital filtering by processing input data x both in the forward and reverse directions. After filtering the data in the forward direction, the function selects the initial conditions to minimize the initial and final transients, reverses the filtered sequence and passes it through the filter in the opposite direction. The result has the following characteristics:
Zero phase distortion;
The transfer function of the filter is equal to the square of the modulus of the original transfer function of the filter;
The filter order is twice as large as the filter order given by the coefficients b and a.
Function filtfilt implements the algorithm proposed by Gustafsson [1].
Do not use filtfilt with differentiating and FIR Hilbert filters, since the operation of these filters strongly depends on their phase characteristics.
y = filtfilt(sos, g, x)` — performs zero-phase filtering of input data x using a second-order (biquadrate) filter represented by a matrix sos and scale values g.
y = filtfilt(B, A, x, "ctf") — performs zero-phase filtering of input data x using Cascaded Transfer Functions (CTF), determined by the coefficients of the numerator and denominator B and A accordingly.
Specify the "ctf" option to eliminate ambiguity between the matrix. B and the matrix sos when you specify A like a scalar or a vector.
y = filtfilt({B, A, g}, x) — performs zero-phase filtering of input data x using CTF and scale values g.
Arguments
Input arguments
#b —
coefficients of the numerator of the transfer function
+
vector
Details
The coefficients of the numerator of the transfer function in the form of a vector. If you are using a filter with all poles, then install b an equal 1. If you are using a filter with all zeros (FIR), then set a an equal 1.
Data types
Float64, Float32
Support for complex numbers
None
#a —
coefficients of the denominator of the transfer function
+
vector
Details
Coefficients of the denominator of the transfer function in the form of a vector. If you are using a filter with all poles, then install b an equal 1. If you are using a filter with all zeros (FIR), then set a an equal 1.
An input signal specified as a vector, matrix, or N-dimensional array with real or complex values. Argument x must have a finite value. Length x must be three times the filter order, defined as max(length(B)-1, length(A)-1). The function acts on the first dimension of the array x unless x it is not a vector string. If x If the vector is a string, then the function acts in the second dimension.
Coefficients of the second-order sections, specified as a matrix. Argument sos — this is a matrix of size on 6, where is the number of sections must be greater than or equal to 2. If the number of sections is less 2, then the function processes the input data as a vector of numerators. Each line sos corresponds to the coefficients of the second-order (biquadrate) filter, - I’m a string sos respond [bi(1) bi(2) bi(3) ai(1) ai(2) ai(3)].
Scale values specified as a real scalar or length vector , where — the number of CTF sections. The scale values represent the distribution of the filter gain across the sections of the cascade representation of the filter.
Function filtfilt Applies the gain to the filter sections using the function scaleFilterSections depending on the specified value g:
The scalar function distributes the gain evenly over all sections of the filter.
The vector function applies the first applies the gain values to the corresponding filter sections and distributes the last gain value evenly across all filter sections.
Data types
Float64, Float32
Support for complex numbers
None
#B —
coefficients of the numerator of the cascade transfer function
+
scalar | vector | the matrix
Details
The coefficients of the numerator of the cascade transfer function (CTF) are set as a scalar, vector, or matrix.
Dimension B There must be on , where — number of filter sections, — the order of the numerators of the filter.
If any input argument is specified as a type Float32 Then filtfilt performs a filtering operation using single precision arithmetic and returns y as a type Float32. Otherwise filtfilt returns y as a type Float64.
Data types
Float64, Float32
Support for complex numbers
Yes
Additional Info
Cascading transfer functions
Details
Dividing 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 through transfer functions it has the form:
Setting digital filters in CTF format
Details
You can set digital filters in CTF format for signal analysis, visualization, and filtering. The filter is determined by enumerating its coefficients B and A. You can also enable the section scaling factor of the filter by specifying g in the form of a scalar or vector.
coeffects of the filter
When you specify the coefficients as matrices with - in rows:
, ,
it is assumed that you have specified the filter as a sequence. cascade transfer functions, so that the total transfer function of the filter is:
where — the order of the numerator of the filter, and — the order of the denominator.
If and given as vectors, it is assumed that the basic system is a single-section IIR filter (), where represents the numerator of the transfer function, and — its denominator.
If If is a scalar, then it is assumed that the filter is a cascade of IIR filters with a full pole, with each section having a total system gain of .
If If is a scalar, then it is assumed that the filter is a cascade of FIR filters, with each section having a total system gain of .
coeffects and amplification
If you have a common scaling factor or several scaling factors that are outside the values of the coefficients, then you can specify the coefficients and gain as an array of cells of the form {B,A,g}. Scaling the filter sections is especially important when working with fixed-point arithmetic to ensure that the output of each filter section has similar amplitude levels, which helps to avoid inaccuracies in the filter response due to limited numerical accuracy.
The gain can be a general scalar gain factor or a vector of section gain factors.
If the gain is scalar, then its value is evenly applied to all sections of the cascade filter.
If the gain factor is a vector, then it must contain one element more than the number of sections. cascade filter. Each of the first The scale value is applied to the corresponding filter section, and the last value is applied evenly to all sections of the cascade filter.
If you specify the coefficient matrices and the gain vector as:
, , ,
then it is assumed that the transfer function of the filter system is:
Literature
Gustafsson, F. “Determining the initial states in forward-backward filtering.” IEEE® Transactions on Signal Processing. Vol. 44, April 1996, pp. 988–992. https://doi.org/10.1109/78.492552.
Lyons, Richard G. Understanding Digital Signal Processing. Upper Saddle River, NJ: Prentice Hall, 2004.
Mitra, Sanjit K. Digital Signal Processing. 2nd Ed. New York: McGraw-Hill, 2001.
Oppenheim, Alan V., and Ronald W. Schafer, with John R. Buck. Discrete-Time Signal Processing. 2nd Ed. Upper Saddle River, NJ: Prentice Hall, 1999.