Main Content

IIR Filter

Implement infinite impulse response (IIR) filter

Since R2020a

Libraries:
Motor Control Blockset / Signal Management
Motor Control Blockset HDL Support / Signal Management

Description

The IIR Filter block implements a discrete first-order infinite impulse response (IIR) filter on the specified input signal. The block supports fixed-point and floating-point data types. The block is also optimized for code generation when you use it with the model settings and configuration adopted by the examples shipped with Motor Control Blockset™.

It is recommended that you use a fixed-step discrete solver for this block to enable code generation and ensure accurate simulation.

Equations

You can configure the IIR filter by using the filter coefficient (a) block parameter to set the required cutoff frequency (fc) for the filter. Optionally, you can also provide the filter coefficient value through an input port.

If you know the cutoff frequency of the filter, you can compute the required filter coefficient using this equation:

a= ( 2πTsfc2πTsfc+1 )

The block also includes the option of displaying the cutoff frequency for a given filter coefficient and sample time on the block mask.

Use the Filter type parameter to configure the block either as a lowpass or highpass filter.

The following two equations describe how the block computes its output.

Lowpass Filter:

y(k)=ax(k)+(1a)y(k1)

Highpass Filter:

y(k)=(1a)[x(k)x(k1)+y(k1)]

where:

  • fc is the cutoff frequency of the IIR filter.

  • a is the filter coefficient (0 < a ≤ 1).

  • y(k) is the output value at time k.

  • y(k1) is the output value at time k1.

  • x(k) is the input value at time k.

  • x(k1) is the input value at time k1.

  • Ts is the sample time of the IIR Filter block.

Ports

Input

expand all

Sampled values of the raw input signal in the time domain.

Data Types: single | double | fixed point

Filter coefficient of the IIR filter. The data type of this signal must be same as that of the input signal x. This may restrict the signal precision when used with fixed point data type.

Dependencies

To enable this port, set the Filter coefficient parameter to Input port.

Data Types: single | double | fixed point

Output

expand all

Filtered output signal returned by the IIR Filter block in the time domain.

Data Types: single | double | fixed point

Parameters

expand all

Type of IIR filter.

Select one of these methods to specify the filter coefficient:

  • Specify via dialog — Select this option if you want to specify the filter coefficient value using the block parameters dialog box.

  • Input port — Select this option if you want to specify the filter coefficient value using an input port.

Filter coefficient of the IIR filter. The data type of this signal must be same as that of the input signal x. This may restrict the signal precision when used with fixed point data type.

Dependencies

To enable this parameter, set the Filter coefficient parameter to Specify via dialog.

Select this parameter for the block to display the Theoretical cutoff frequency (Hz) parameter.

Dependencies

To enable this parameter, set the Filter coefficient parameter to Specify via dialog.

The fixed time interval (in seconds) between every two consecutive instances of block execution.

Note

The block uses this value to compute and display the Theoretical cutoff frequency (Hz) in the block dialog box. This parameter does not set the sample time of the block. The block inherits the sample time from the model.

Dependencies

To display this parameter:

  • Set the Filter coefficient parameter to Specify via dialog.

  • Select the Display cutoff frequency parameter.

Computed theoretical cutoff frequency (in Hertz) of the IIR filter. This parameter is not configurable.

Dependencies

To display this parameter:

  • Set the Filter coefficient parameter to Specify via dialog.

  • Select the Display cutoff frequency parameter.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Fixed-Point Conversion
Design and simulate fixed-point systems using Fixed-Point Designer™.

Version History

Introduced in R2020a