FILTEQ

Purpose:

Evaluates a Linear Constant Coefficient Difference Equation.

Syntax:

FILTEQ(b, a, x, yi, xi)

(y, zf) = FILTEQ(b, a, x, zi)

(y, yf, xf) = FILTEQ(b, a, x, yi, xi)

 

b

-

A series, x[n] coefficients.

a

-

A series, y[n] coefficients.

x

-

A series, the input data.

zi

-

Optional. A series, the initial conditions in difference equation state form.

yi

-

Optional. A series, the y[-k] initial conditions.

xi

-

Optional. A series, the x[-k] initial conditions.

Returns:

A series.

 

(y, zf) = FILTEQ(b, a, x, zi)  returns the filtered series and final conditions in difference equation state form.

 

(y, yf, xf) = FILTEQ(b, a, x, yi, xi)  returns the filtered series and final conditions in difference equation direct form.

Example:

x = {1, 0, 0, 0, 0}

y = filteq({1, -0.5}, {0.8, -0.2, -0.5}, x)

 

y == {1.0, 0.3, 0.04, -0.528, -0.5804}

 

y is the output produced by the difference equation:

 

image\filteq01.gif

Example:

W1: gimpulse(1024,1)

W2: filteq({1,-0.5}, {0.8,-0.2,-0.5},W1)

W3: spectrum(W2);setxlog(1);setylog(1,0,1)

 

image\filteq.gif

 

calculates 1024 samples of the impulse response of the above difference equation. The spectrum in W3 shows a resonate peak at approximately 0.127 Hertz.

Example:

x = {1, 0, 0, 0, 0}

y = filteq({1, -0.5}, {1, -0.2, -0.5}, x)

 

y == {1.0, -0.3, 0.44, -0.062, 0.2076}

 

Because a[1] = 1, y is the output produced by the difference equation:

 

image\filteq02.gif

 

or the equivalent Z-transform:

 

image\filteq03.gif

Example:

b = {1, -0.5};

a = {1, 0.5, -0.5};

 

W1: gnorm(200, 1);

W2: filteq(b, a, w1);

W3: extract(w1, 1, int(length(w1)/2));

W4: extract(w1, 1 + int(length(w1)/2), -1);

W5: (y, zf) = filteq(b, a, w3);y;

W6: filteq(b, a, w4, zf);

W7: concat(w5, w6);

W8: w2 - w7;

 

W1 contains 200 samples of random noise.

W2 filters the series with a finite difference equation.

W3 and W4 divide the series in W1 into two segments.

W5 filters the first segment and returns the final conditions.

W6 filters the second segment setting the initial conditions to the final conditions of W5.

W7 combines the output results and W8 shows the two processes return the same. The initial and final conditions are represented in difference equation state form.

Example:

b = {1, -0.5};

a = {1, 0.5, -0.5};

 

W1: gnorm(200, 1);

W2: filteq(b, a, w1);

W3: extract(w1, 1, int(length(w1)/2));

W4: extract(w1, 1 + int(length(w1)/2), -1);

W5: (y, iirzf, firzf) = filteq(b, a, w3);y;

W6: filteq(b, a, w4, iirzf, firzf);

W7: concat(w5, w6);

W8: w2 - w7;

 

Same as above except the initial and final conditions are represented in difference equation direct form.

Remarks:

If a[1] ≠ 1, FILTEQ evaluates a linear constant coefficient difference equation of the following form:

 

image\zfreq03.gif

 

or equivalently:

 

image\filteq06.gif

 

If the initial conditions zi are provided as a single series, the values are assumed to be in difference equation state form.

If two series yi and xi are provided, yi specifies the initial conditions y[0], y[-1], ..., y[-L] and xi specifies initial conditions x[0], x[-1], ..., x[-L].

If no initial conditions are provided, both yi and xi are assumed to be 0.

 

If a[1] = 1, the coefficients are assumed to be in standard Z-transform form:

 

image\grp03.gif

 

z 

= 

e jω complex frequency

N

=

number of numerator terms

M

=

number of denominator terms

 

This form represents the following difference equation:

 

image\filteq07.gif

 

See CASCADE to filter data implemented by an IIR filter of cascaded 2nd order stages.

 

See SOSFILT to process a filter implemented with coefficients in second order section form.

See Also:

CASCADE

CONV

FPADFILT

IMPZ

INVFREQS

PADFILT

SOSFILT

ZFREQ

ZPLANE