Signal Processing Toolbox Help Desk

filter

Purpose

Filter data with a recursive (IIR) or nonrecursive (FIR) filter.

Syntax

Description

filter is part of the MATLAB environment. It filters data using a digital filter. The filter realization is the transposed direct form II structure [1], which can handle both FIR and IIR filters.

If a(1) 1, filter normalizes the filter coefficients by a(1). If a(1) = 0, the input is in error.

y = filter(b,a,x) filters the data in vector x with the filter described by coefficient vectors a and b to create the filtered data vector y. When x is a matrix, filter operates on the columns of x. When x is an N-dimensional array, filter operates on the first non-singleton dimension.

[y,zf] = filter(b,a,x) returns the final values of the states in the vector zf.

[...] = filter(b,a,x,zi) specifies initial state conditions in the vector zi.

The size of the initial/final condition vector is max(length(b),length(a))-1. zi or zf can also be an array of such vectors, one for each column of x if x is a matrix. If x is a multidimensional array, filter works across the first nonsingleton dimension of x by default.

[...] = filter(b,a,x,zi,dim) works across the dimension dim of x. Set zi to empty to get the default initial conditions.

filter works for both real and complex inputs.

Example

Find and graph the 100-point unit impulse response of a digital filter:

Algorithm

filter is a built-in MATLAB function. filter is implemented as a transposed direct form II structure

where n-1 is the filter order.

The operation of filter at sample m is given by the time domain difference equations for y and the states zi :

You can use filtic to generate the state vector zi(0) from past inputs and outputs.

The input-output description of this filtering operation in the z-transform domain is a rational transfer function:

Diagnostics

If a(1) = 0, filter gives the following error message:

If the length of the initial condition vector is not the greater of na and nb, filter gives the following error message:

See Also

fftfilt

FFT-based FIR filtering using the overlap-add method.

filter2

Two-dimensional digital filtering.

filtfilt

Zero-phase digital filtering.

filtic

Make initial conditions for filter function.

References

[1] Oppenheim, A.V., and R.W. Schafer. Discrete-Time Signal Processing. Englewood Cliffs, NJ: Prentice Hall, 1989. Pgs. 311-312.



[ Previous | Help Desk | Next ]