Main Content

filter

Modify frequency content of timeseries objects

Description

tsout = filter(tsin,b,a) applies the rational transfer function filter b(z−1)/a(z−1) to the uniformly-spaced data in the timeseries object tsin. The numerator b and denominator a are vectors containing the transfer function coefficients.

tsout = filter(tsin,b,a,ind) specifies the indices of the columns or rows to filter. ind is a vector of integers representing column indices for column-oriented data (tsin.IsTimeFirst is true) and representing row indices for row-oriented data (tsin.IsTimeFirst is false).

Examples

collapse all

This example applies the following transfer function to a set of data:

H(z-1)=b(z-1)a(z-1)=2+3z-11+0.2z-1

Create a timeseries object from the matrix count in count.dat.

load count.dat
tsin = timeseries(count(:,1),[1:24]);

Enter the coefficients for the denominator and numerator of the transfer function. Order the coefficients in ascending powers of z-1 to represent 1+0.2x and 2-3z-1.

a = [1 0.2];
b = [2 3];

Apply the transfer function using filter, and compare the original data to the filtered data.

tsout = filter(tsin,b,a);
plot(tsin)
hold on
plot(tsout)
legend('Original Data','Filtered Data','Location','NorthWest')

Figure contains an axes object. The axes object with title Time Series Plot:unnamed, xlabel Time (seconds), ylabel unnamed contains 2 objects of type line. These objects represent Original Data, Filtered Data.

Input Arguments

collapse all

Input timeseries, specified as a scalar. tsin must be uniformly sampled.

Data Types: timeseries

Numerator coefficients of the transfer function, specified as a scalar or vector.

Denominator coefficients of the transfer function, specified as a scalar or vector.

Row or column indices, specified as a positive integer numeric scalar or vector. ind represents column indices for column-oriented data (tsin.IsTimeFirst is true) and represents row indices for row-oriented data (tsin.IsTimeFirst is false).

Data Types: double | single | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

More About

collapse all

Rational Transfer Function

The input-output description of the filter operation on a vector in the Z-transform domain is a rational transfer function. A rational transfer function is of the form,

Y(z)=b(1)+b(2)z1+...+b(nb+1)znb1+a(2)z1+...+a(na+1)znaX(z),

which handles both FIR and IIR filters [1]. na is the feedback filter order, and nb is the feedforward filter order.

You also can express the rational transfer function as the following difference equation,

a(1)y(n)=b(1)x(n)+b(2)x(n1)+...+b(nb+1)x(nnb)a(2)y(n1)...a(na+1)y(nna).

Furthermore, you can represent the rational transfer function using its direct-form II transposed implementation, as in the following diagram. Here, na = nb = n-1.

Block diagram that illustrates the direct-form II transposed implementation of an IIR digital filter with order n-1.

The operation of filter at sample m is given by the time domain difference equations

y(m)=b(1)x(m)+w1(m1)w1(m)=b(2)x(m)+w2(m1)a(2)y(m)       =                 wn2(m)=b(n1)x(m)+wn1(m1)a(n1)y(m)wn1(m)=b(n)x(m)a(n)y(m).

References

[1] Oppenheim, Alan V., Ronald W. Schafer, and John R. Buck. Discrete-Time Signal Processing. Upper Saddle River, NJ: Prentice-Hall, 1999.

Version History

Introduced before R2006a

See Also