Discrete Filter
Model Infinite Impulse Response (IIR) filters
 Library:
Simulink / Discrete
Description
The Discrete Filter block independently filters each channel of the input
signal with the specified digital IIR 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 static filters with fixed coefficients. You can tune the
coefficients of these static filters.
This block filters each channel of the input signal independently over time. The Input processing parameter allows you to specify how the block treats each element of the input. You can specify treating input elements as an independent channel (samplebased processing), or treating each column of the input as an independent channel (framebased processing). To perform framebased processing, you must have a DSP System Toolbox™ license.
The output dimensions equal the input dimensions, except when you specify a matrix of filter taps for the Numerator coefficients parameter. When you do so, the output dimensions depend on the number of different sets of filter taps you specify.
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. Signal processing engineers typically use this method. Conversely, the Discrete Transfer Fcn block lets you use polynomials in z to represent a discrete system. Control engineers typically use this method. When the numerator and denominator polynomials have the same length, the two methods are identical.
Specifying Initial States
In Dialog parameters and Input port(s) modes, the block initializes the internal filter states to zero by default, which is equivalent to assuming past inputs and outputs are zero. You can optionally use the Initial states parameter to specify nonzero initial states for the filter delays.
To determine the number of initial state values you must specify, and how to specify them, see the following table on valid initial states and Number of Delay Elements (Filter States). The Initial states parameter can take one of four forms as described in the following table.
Valid Initial States
Initial state  Examples  Description 

Scalar 
Each delay element for
each channel is set to 
The block initializes all delay elements in the filter to the scalar value. 
Vector 
For a filter with two delay elements: [d_{1}d_{2}] The delay elements for all channels are d1 and d2. 
Each vector element specifies a unique initial condition for a corresponding delay element. The block applies the same vector of initial conditions to each channel of the input signal. The vector length must equal the number of delay elements in the filter (specified in the table Number of Delay Elements (Filter States)). 
Vector or matrix  For a threechannel input signal and a filter with two delay elements: [d_{1}d_{2}D_{1}D_{2}d_{1}d_{2}] or
$$\left[\begin{array}{lll}{d}_{1}\hfill & {D}_{1}\hfill & {d}_{1}\hfill \\ {d}_{2}\hfill & {D}_{2}\hfill & {d}_{2}\hfill \end{array}\right]$$

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

Empty matrix 

The empty matrix, 
The number of delay elements (filter states) per input channel depends on the filter structure, as indicated in the following table.
Number of Delay Elements (Filter States)
Filter Structure  Number of Delay Elements Per Channel 





The following tables describe the valid initial states for different sizes of input and different number of channels depending on whether you set the Input processing parameter to frame based or sample based.
FrameBased Processing
Input  Number of Channels  Valid Initial States (Dialog Box)  Valid Initial States (Input Port) 

 1 


 N 


SampleBased Processing
Input  Number of Channels  Valid Initial States (Dialog Box)  Valid Initial States (Input Port) 

 1 


 N 


 K × N 


When the Initial states is a scalar, the block initializes all filter
states to the same scalar value. Enter 0
to initialize all states
to zero. When the Initial states is a vector or a matrix, each
vector or matrix element specifies a unique initial state. This unique state
corresponds to a delay element in a corresponding channel:
The vector length must equal the number of delay elements in the filter,
M = max(number of zeros, number of poles)
.The matrix must have the same number of rows as the number of delay elements in the filter,
M = max(number of zeros, number of poles)
. The matrix must also have one column for each channel of the input signal.
The Specify a Vector of Initial Conditions for a Discrete Filter Block example shows the relationship between the initial filter output and the initial input and state. Given an initial input u_{1}, the first output y_{1} is related to the initial state [x_{1}, x_{2}] and initial input by:
$${y}_{1}={b}_{1}\left[\frac{\left({u}_{1}{a}_{2}{x}_{1}{a}_{3}{x}_{2}\right)}{{a}_{1}}\right]+{b}_{2}{x}_{1}+{b}_{3}{x}_{2}$$
Ports
Input
Output
Parameters
Model Examples
Block Characteristics
Data Types 

Direct Feedthrough 

Multidimensional Signals 

VariableSize Signals 

ZeroCrossing Detection 

^{[a]} This block only supports signed fixedpoint data types. 
Extended Capabilities
See Also
Discrete FIR Filter  Allpole Filter (DSP System Toolbox)  Digital Filter Design (DSP System Toolbox)  Filter Realization Wizard (DSP System Toolbox)  dsp.IIRFilter
(DSP System Toolbox)  dsp.AllpoleFilter
(DSP System Toolbox)  filterDesigner
(DSP System Toolbox)  fvtool
(Signal Processing Toolbox)
Topics
 Sample and FrameBased Concepts (DSP System Toolbox)
 Working with States