Main Content


Modify frequency content of timeseries objects


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).


collapse all

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


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);
hold on
legend('Original Data','Filtered Data','Location','NorthWest')

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,


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,


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).


[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