Signal Processing Toolbox    
filter

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

Syntax

Description

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 nonsingleton dimension. a(1) cannot be 0, and if a(1)  1, filter normalizes the filter coefficients by a(1).

[y,zf] = filter(b,a,x) returns the final values zf of the state vector. When x is a vector, the size of the final condition vector zf is max(length(b),length(a))-1, the number of delays in the filter. When x is a multidimensional array, zf is an s-by-c matrix, where:

[...] = filter(b,a,x,zi) specifies initial state conditions in the vector zi. The size of the initial condition vector zi must be the same as max(length(b),length(a))-1, the number of delays in the filter.

[...] = filter(b,a,x,zi,dim) filters the input data located along the dimension dim of x. Set zi to the empty vector [] to use zero initial conditions.

The filter function is part of the standard MATLAB language.

Examples

Find and graph the 101-point unit impulse response of a digital filter.

Algorithm

filter is implemented as a transposed direct form II structure [1], as shown below

where n-1 is the filter order. The state vector z is a vector whose components are derived from the values of the inputs to each delay in the filter.

The operation of filter at sample m is implemented using the transposed direct form II structure. This is calculated by the time domain difference equations for y and the states zi.

Note the division by a(1). For efficient computation, select this coefficient to be a power of 2.

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.

See Also

fftfilt, filter2, filtfilt, filtic

References

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


 fftshift filter2