Zero-phase digital filtering
y
=
filtfilt(b,a,x)
y = filtfilt(SOS,G,x)
y = filtfilt(d,x)
y
performs zero-phase digital filtering by processing the
input data, =
filtfilt(b,a,x)x
, in both the forward and reverse
directions [1]. filtfilt
operates
along the first nonsingleton dimension of x
. The
vector b
provides the numerator coefficients of
the filter and the vector a
provides the denominator
coefficients. If you use an all-pole filter, enter 1
for b
.
If you use an all-zero filter (FIR), enter 1
for a
.
After filtering the data in the forward direction, filtfilt
reverses
the filtered sequence and runs it back through the filter. The result
has the following characteristics:
Zero-phase distortion
A filter transfer function, which equals the squared magnitude of the original filter transfer function
A filter order that is double the order of the filter
specified by b
and a
filtfilt
minimizes start-up and
ending transients by matching initial conditions, and you can use
it for both real and complex inputs. Do not use filtfilt
with
differentiator and Hilbert FIR filters, because the operation of these
filters depends heavily on their phase response.
Note:
The length of the input |
y = filtfilt(SOS,G,x)
zero-phase filters
the data, x
, using the second-order section (biquad)
filter represented by the matrix SOS
and scale
values G
. SOS
is an L-by-6
matrix containing the L second-order sections. SOS
must
be of the form
$$\left(\begin{array}{cccccc}{b}_{01}& {b}_{11}& {b}_{21}& {a}_{01}& {a}_{11}& {a}_{21}\\ {b}_{02}& {b}_{12}& {b}_{22}& {a}_{02}& {a}_{12}& {a}_{22}\\ \vdots & \vdots & \vdots & \vdots & \vdots & \vdots \\ {b}_{0L}& {b}_{1L}& {b}_{2L}& {a}_{0L}& {a}_{1L}& {a}_{2L}\end{array}\right)$$
where each row are the coefficients of a biquad
filter. The vector of filter scale values, G
, must
have a length between 1 and L + 1.
Note:
When implementing zero-phase filtering using a second-order
section filter, the length of the input, |
y = filtfilt(d,x)
zero-phase filters the
input data, x
, using a digital filter, d
.
Use designfilt
to generate d
based
on frequency-response specifications.
[1] Oppenheim, Alan V., Ronald W. Schafer, and John R. Buck. Discrete-Time Signal Processing. 2nd Ed. Upper Saddle River, NJ: Prentice Hall, 1999.
[2] Mitra, Sanjit K. Digital Signal Processing. 2nd Ed. New York: McGraw-Hill, 2001, secs. 4.4.2 and 8.2.5.
[3] Gustafsson, F. "Determining the initial states in forward-backward filtering." IEEE^{®} Transactions on Signal Processing. Vol. 44, April 1996, pp. 988–992.
designfilt
| digitalFilter
| fftfilt
| filter
| filter2