Engee documentation

Discrete Filter

Infinite impulse response (IIR) filter model.

discrete filter

Description

The Discrete Filter block independently filters each channel of the input signal with the specified digital NIR filter. You can specify the filter structure as Direct form I, Direct form I transposed, Direct form II or Direct form II transposed.

The block implements a static filter with fixed coefficients. Each channel of the input signal is filtered independently in time.

The Numerator coefficients parameter specifies the filter numerator polynomial coefficients. The Denominator coefficients parameter sets the coefficients of the denominator polynomial of the function.

The coefficients of the numerator and denominator polynomials are set in ascending order of degrees . The Discrete Filter block allows you to use polynomials in (delay operator) to represent a discrete system. This approach is typically used in digital signal processing (DSP). In contrast, the Discrete Transfer Fcn block allows polynomials from to be used to represent a discrete system. This approach is more common in control systems. When the numerator and denominator polynomials have the same length, the two approaches are equivalent.

Initial states

  • If the initial value is a scalar, then this initial value is used for each channel for each delay.

  • If the initial value is an array, then the dimension expansion is used.

    Consider an example. Let the initial value be [s1, s2, s3]. In that case it is a column vector, so it can be written as follows for clarity:

    [
    s1,
    s2,
    s3,
    ]

    Suppose we have one channel. Then s1 is the initial condition for the first delay, s2 for the second delay, etc. If there are several channels, all this is true for each separate channel.

    The second example is [s1 s2 s3]. This is a row matrix. If the filter has three delays, then after expanding the dimensionality, the initial conditions are:

    [
    s1 s2 s3;
    s1 s2 s3;
    s1 s2 s3;
    ]

    In this case, the initial conditions for the first channel delays are [s1, s1, s1], for the second channel delays are [s2, s2, s2], and so on.

    It is possible that the number of dimensions is larger. The general rule: the first dimension corresponds to initial conditions for different delays, the following dimensions correspond to different channels. Channels can be elements not only of a vector, but also of a matrix and arrays of higher dimensions.

The number of delays is determined as written above. For Direct form I and Direct form I transposed the number of delays for the numerator equals the length of the numerator minus 1, for the denominator equals the length of the denominator minus 1. For Direct form II and Direct form II transposed the maximum of the denominator and numerator lengths minus 1.

The Initial states parameter specifies the initial states for filter delays.

How to determine the number of initial state values to be set and how exactly to set them is described in the table below. It gives permissible initial states and the number of delay elements (filter states). The Initial states parameter can take one of four forms as described in the table.

Initial state Examples Description

Scalar

5

Each delay element for each channel is set to 5.

The block initialises all delay elements in the filter with a scalar value of

Vector or matrix (to apply different delay elements to each channel)

For a three-channel input signal and a filter with two delay elements:

] or

The delay elements for channel 1 are и .

The delay elements for channel 2 are и .

The delay elements for channel 3 are и .

Each element of the vector or matrix specifies a unique initial condition for the corresponding delay element in the corresponding channel:

  • The length of the vector must be equal to the product of the number of input channels and the number of delay elements in the filter.

  • The matrix must have the same number of rows as the number of delay elements in the filter and must have one column for each input channel.

Ports

Input

u - input signal
scalar | vector | matrix | multidimensional array

An input signal specified as a scalar, vector, matrix or array with any number of dimensions.

Data types: Float16, Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Bool.

Output

Port_1 - filtered signal
scalar | vector | matrix | multidimensional array

Filtered output signal.

Data types: Float64.

Parameters

Filter Structure - filter structure
Direct form II (by default) | Direct form I transposed | Direct form I | Direct form II transposed

Sets the discrete structure of the IIR filter.

Usage in program code

Block parameter

FilterStructure

Values

Direct form II | Direct form I transposed | Direct form I | Direct form II transposed

By default

Direct form II

Numerator coefficients - numerator coefficients
[1.0] (by default) | scalar | vector | matrix | multidimensional array

Numerator coefficients of a discrete filter as decreasing degrees of z. Use a column vector to specify the coefficients for a single polynomial of the numerator.

Usage in program code

Block parameter

Numerator

Values

scalar | vector | matrix

By default

[1.0]

Denominator coefficients - denominator coefficients
[1.0, 0.5] (by default) | scalar | vector | matrix | multidimensional array

Denominator coefficients of a discrete filter as decreasing degrees of z. Use a column vector to specify the coefficients for a polynomial with a single denominator.

Usage in program code

Block parameter

Denominator

Values

scalar | vector | matrix

By default

[1.0, 0.5]

Initial states - initial states of the filter
0.0 (by default) | scalar | vector | matrix | multidimensional array

Initial filter states as a scalar, vector or matrix.

Dependencies

To use this port, set the Filter Structure parameter to Direct form II or Direct form II transposed.

Usage in program code

Block parameter

InitialStates

Values

scalar | vector | matrix

By default

0.0

Initial states on numerator side - initial states of numerator
0.0 (by default) | scalar | vector | matrix

Specify the initial states of the filter numerator as a scalar, vector or matrix.

Dependencies

To use this port, set the Filter Structure parameter to Direct form I or Direct form I transposed.

Usage in program code

Block parameter

InitialStatesNumSide

Values

scalar | vector | matrix

By default

0.0

Initial states on denominator side - initial states of denominator
0.0 (by default) | scalar | vector | matrix

Initial states of the filter denominator as a scalar, vector or matrix.

Dependencies

To use this port, set the Filter Structure parameter to Direct form I or Direct form I transposed.

Usage in program code

Block parameter

InitialDenominatorStates

Values

scalar | vector | matrix

* By default*

0.0

Sample time (-1 for inherited) - interval between calculation steps
-1.0 (by default) | scalar

Specify the interval between calculation steps as a non-negative number. To inherit the calculation step, set this parameter to -1.

Usage in program code

Block parameter

SampleTime

Values

scalar | vector

By default

-1.0