| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink |
| Contents | Index |
| Learn more about Simulink |
Discrete

The Discrete Filter block independently filters each channel of the input signal with the specified digital IIR direct form II filter. The block implements static filters with fixed coefficients. You can tune the coefficients of a static filter.
This block filters each channel of the input signal independently over time, treating each element of the input as an individual channel. The output dimensions always equal the dimensions of the filtered input signal, except in single-input/multi-output mode.
The output of this block numerically matches the output of the Signal Processing Toolbox™ dfilt.df2 function.
Use the Numerator coefficients parameter to specify the coefficients of the discrete filter numerator polynomial. Use the Denominator coefficients parameter to specify the coefficients of the denominator polynomial of the function. The Denominator coefficients parameter must be a vector of coefficients.
Specify the coefficients of the numerator and denominator polynomials in ascending powers of z-1. The Discrete Filter block lets you use polynomials in z-1 (the delay operator) to represent a discrete system, a method that signal processing engineers typically use. Conversely, the Discrete Transfer Fcn block lets you use polynomials in z to represent a discrete system, the method that control engineers typically use. The two methods are identical when the numerator and denominator polynomials have the same length.
Use the Initial states parameter to specify initial filter states. To determine the number of initial states you must specify and how to specify them, see the following table of valid initial state dimensions. The Initial states parameter can take one of the forms described in this table.
Valid Initial States
| Initial States | Description |
|---|---|
Scalar | The block initializes all filter states to the same scalar value. Enter 0 to initialize all states to zero. |
Vector or matrix | Each vector or matrix element specifies a unique initial state for a corresponding delay element in a corresponding channel:
|
The following example shows the relationship between the initial filter output and the initial input and state. Given an initial input u1, the first output y1 is related to the initial state [x1, x2] and initial input by:
![]()
Initial States: 1

The Discrete Filter block accepts and outputs real and complex signals of any signed numeric data type that Simulink supports. The block supports the same types for the numerator and denominator coefficients.
Numerator and denominator coefficients must have the same complexity. They can have different word lengths and fraction lengths.
States are complex when either the input or the coefficients are complex.
The following diagrams show the filter structure and the data types used within the Discrete Filter block for fixed-point signals.

The block omits the dashed divide when you select the Optimize by skipping divide by leading denominator coefficient (a0) parameter.

The Main pane of the Discrete Filter block dialog box appears as follows.

Specify the coefficients of the discrete filter numerator polynomial or polynomials in ascending powers of z-1. Use a row vector to specify the coefficients for a single numerator polynomial.
Specify the coefficients of the discrete filter denominator polynomial as a row vector in ascending powers of z-1.
Specify the initial states of the filter. To learn how to specify initial states, see Specifying Initial States.
Specify the time interval between samples. To inherit the sample time, set this parameter to -1. See How to Specify the Sample Time.
Select when the leading denominator coefficient, a0, equals one. This parameter generates optimized code.
When you select this check box, the block:
Does not perform a divide-by-a0 either in simulation or in the generated code
Errors out at model edit time if the a0 value you provide in the dialog is not one
Errors out if you tune a0 to any nonunity value
When you clear this check box, the block:
Has denominator coefficients that are fully tunable during simulation
Performs a divide-by-a0 in both simulation and code generation
The Data Types pane of the Discrete Filter block dialog box appears as follows.

Specify the state data type. You can set it to:
A rule that inherits a data type, for example, Inherit: Same as input
A built-in integer, for example, int8
A data type object, for example, a Simulink.NumericType object
An expression that evaluates to a data type, for example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the State parameter.
See Using the Data Type Assistant for more information.
Specify the numerator coefficient data type. You can set it to:
A rule that inherits a data type, for example, Inherit: Inherit via internal rule
A built-in integer, for example, int8
A data type object, for example, a Simulink.NumericType object
An expression that evaluates to a data type, for example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the Numerator
coefficients parameter.
See Using the Data Type Assistant for more information.
Specify the minimum value that a numerator coefficient can have. The default value, [], is equivalent to -Inf. Simulink software uses this value to perform:
Parameter range checking (see Checking Parameter Values)
Automatic scaling of fixed-point data types
Specify the maximum value that a numerator coefficient can have. The default value, [], is equivalent to Inf. Simulink software uses this value to perform:
Parameter range checking (see Checking Parameter Values)
Automatic scaling of fixed-point data types
Specify the product output data type for the numerator coefficients. You can set it to:
A rule that inherits a data type, for example, Inherit: Inherit via internal rule
A built-in data type, for example, int8
A data type object, for example, a Simulink.NumericType object
An expression that evaluates to a data type, for example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the Numerator
product output parameter.
See Using the Data Type Assistant for more information.
Specify the accumulator data type for the numerator coefficients. You can set it to:
A rule that inherits a data type, for example, Inherit: Inherit via internal rule
A built-in data type, for example, int8
A data type object, for example, a Simulink.NumericType object
An expression that evaluates to a data type, for example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the Numerator
accumulator parameter.
See Using the Data Type Assistant for more information.
Specify the denominator coefficient data type. You can set it to:
A rule that inherits a data type, for example, Inherit: Inherit via internal rule
A built-in integer, for example, int8
A data type object, for example, a Simulink.NumericType object
An expression that evaluates to a data type, for example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the Denominator
coefficients parameter.
See Using the Data Type Assistant for more information.
Specify the minimum value that a denominator coefficient can have. The default value, [], is equivalent to -Inf. Simulink software uses this value to perform:
Parameter range checking (see Checking Parameter Values)
Automatic scaling of fixed-point data types
Specify the maximum value that a denominator coefficient can have. The default value, [], is equivalent to Inf. Simulink software uses this value to perform:
Parameter range checking (see Checking Parameter Values)
Automatic scaling of fixed-point data types
Specify the product output data type for the denominator coefficients. You can set it to:
A rule that inherits a data type, for example, Inherit: Inherit via internal rule
A built-in data type, for example, int8
A data type object, for example, a Simulink.NumericType object
An expression that evaluates to a data type, for example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the Denominator
product output parameter.
See Using the Data Type Assistant for more information.
Specify the accumulator data type for the denominator coefficients. You can set it to:
A rule that inherits a data type, for example, Inherit: Inherit via internal rule
A built-in data type, for example, int8
A data type object, for example, a Simulink.NumericType object
An expression that evaluates to a data type, for example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the Denominator
accumulator parameter.
See Using the Data Type Assistant for more information.
Specify the output data type. You can set it to:
A rule that inherits a data type, for example, Inherit: Inherit via internal rule
A built-in data type, for example, int8
A data type object, for example, a Simulink.NumericType object
An expression that evaluates to a data type, for example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the Output parameter.
See Specifying Block Output Data Types for more information.
Specify the minimum value that the block can output. The default value, [], is equivalent to -Inf. Simulink software uses this value to perform:
Simulation range checking (see Checking Signal Ranges)
Automatic scaling of fixed-point data types
Specify the maximum value that the block can output. The default value, [], is equivalent to Inf. Simulink software uses this value to perform:
Simulation range checking (see Checking Signal Ranges)
Automatic scaling of fixed-point data types
Select to lock all data type settings of this block against changes by the Fixed-Point Tool and the Fixed-Point Advisor. For more information, see Fixed-Point Tool and Fixed-Point Advisor in the Simulink Fixed Point documentation.
Select the rounding mode for fixed-point operations. For more information, see Rounding in the Simulink Fixed Point User's Guide.
Select this check box to have overflows saturate. Otherwise, they wrap.
When you select this check box, saturation applies to every internal operation on the block, not just the output or result. In general, the code generation process can detect when overflow is not possible, in which case, no saturation code is necessary.
The State Attributes pane of the Discrete Filter block dialog box appears as follows.

Use this parameter to assign a unique name to each state. The default is ' '. When this field is blank, no name is assigned. Consider the following when using this parameter:
To assign a name to a single state, enter the name between quotes, for example, 'velocity'.
The state names apply only to the selected block.
To assign names to multiple states, enter a comma-delimited list surrounded by braces, for example, {'a', 'b', 'c'} . Each name must be unique.
The number of states must be an integer multiple of the number of state names. You can have fewer names than states, but you cannot have more names than states. For example, you can specify two names in a system with four states. Simulink software assigns the first name to the first two states and the second name to the last two.
To assign state names with a variable that you have defined in the MATLAB workspace, enter the variable without quotes. A variable can be a string, cell, or structure.
This parameter enables State name must resolve to Simulink signal object when you click Apply.
Select this check box to require that the state name resolves to a Simulink signal object. This check box is cleared by default.
Specifying the State name parameter enables this parameter.
Selecting this check box enables Real-Time Workshop storage class.
From the list, select the state storage class.
If you do not need states to interface to external code, select Auto as the storage class.
The class stores the state in a global variable.
model_private.h declares the state as an extern variable.
model_private.h declares the state as an extern pointer.
Specifying the State name parameter enables this parameter.
Setting this parameter to ExportedGlobal, ImportedExtern, or ImportedExternPointer enables Real-Time Workshop storage type qualifier.
During simulation, the block uses the following values:
The initial value of the signal object to which the state name resolves
Minimum and maximum values of the signal object
See Block State Storage and Interfacing Considerations in the Real-Time Workshop User's Guide for more information.
Direct Feedthrough | Only when the leading numerator coefficient is not equal to zero |
Sample Time | Specified in the Sample time parameter |
Scalar Expansion | Yes, of initial states |
States | |
Dimensionalized | Yes |
Zero-Crossing Detection | No |
![]() | Discrete Derivative | Discrete FIR Filter | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |