# filter

## Purpose

Filter data with an infinite impulse response (IIR) or finite impulse response (FIR) filter.

## Synopsis

    y = filter(b,a,x)
    [y,zf] = filter(b,a,x)
    y = filter(b,a,x,zi)

## Description

`filter` filters a data sequence using a digital filter. The filter realization is the transposed direct form II structure, which can handle both FIR and IIR filters [1].

`y = filter(b,a,x)` filters the data in vector `x` with the filter described by numerator coefficient vector `b` and denominator coefficient vector `a` to create the filtered data vector `y`. If `a(1) ~= 1`, `filter` normalizes the filter coefficients by `a(1)`. If `a(1) = 0`, `filter` returns an error.

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

`y = filter(b,a,x,zi)` specifies initial state conditions in vector `zi`.

The size of the initial/final condition vector is `max(size(a),size(b))`.

`filter` works for both real and complex inputs.

## Algorithm

`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

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

## See Also

    filter2
    filtic in the Signal Processing Toolbox

## References

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

(c) Copyright 1994 by The MathWorks, Inc.