| DSP Blockset | ![]() |
Independently filter each channel of the input over time using a specified time-varying or static digital filter implementation
Library
Filtering / Filter Designs
Description
Note
Use this block to efficiently implement floating-point filters that you have already designed. The following blocks also implement digital filters, but serve slightly different purposes:
|
The Digital Filter block independently filters each channel of the input signal with a specified digital IIR or FIR filter. The block can implement static filters with fixed coefficients, as well as time-varying filters with coefficients that change over time. (You can tune the coefficients of a static filter during simulation.)
The block filters each channel of the input signal independently over time. The output size, frame status, dimension, and data type are always the same as those of the input signal that is filtered. When inputs are frame based, the block treats each column as an independent channel (the block filters each column). When inputs are sample based, the block treats each element of the input as an individual channel.
The outputs of the block numerically match the outputs of the Digital Filter Design block, the filter function in the Signal Processing Toolbox, and the filter function in Filter Design Toolbox.
Sections of This Reference Page
Supported Filter Structures
The selection of filter structures offered in the Filter structure parameter depends on whether you set the filter to be IIR with poles and zeros, IIR with all poles, or FIR with all zeros, as summarized in the following table. The table also shows the vector or matrix of filter coefficients you must provide for each filter structure.
For more information on how to specify filter coefficients for various filter structures, see Specifying Static Filters and Specifying Time-Varying Filters.
| Transfer Function Type |
Supported Filter Structures |
Filter Coefficient Specification |
| IIR (poles & zeros) | Direct form I Direct form I transposed Direct form II Direct form II transposed |
|
| Biquadratic direct form II transposed (second-order sections) |
M-by-6 second-order section (SOS) matrix. See Specifying the SOS Matrix (Biquadratic Filter Coefficients). |
|
| IIR (all poles) | Direct form Transposed direct form |
Denominator coefficients vector [a0, a1, a2, ..., am] |
| Lattice AR |
Reflection coefficients vector [k1, k2, ..., kn] |
|
| FIR (all zeros) | Direct form Transposed direct form |
Numerator coefficients vector [b0, b1, b2, ..., bn] |
| Lattice MA |
Reflection coefficients vector [k1, k2, ..., kn] |
Specifying Static Filters
To specify a static filter whose coefficients are fixed in time, set the Coefficient source parameter to Dialog parameter(s). Depending on the filter structure, you need to enter your filter coefficients into one or more of the following parameters. The block disables all the irrelevant parameters. To see which of these parameters correspond to each filter structure, see Table 7-3, Filter Structures and Filter Coefficients:
Tuning the Filter Coefficient Values During Simulation. You can change the value of the static filter coefficients during a running simulation. To tune the coefficients during a simulation, double-click the block, type in the new vector(s) of filter coefficients, and click Apply. You cannot change the filter order, so you cannot change the number of elements in the vector(s) of filter coefficients.
Specifying Time-Varying Filters
Time-varying filters are filters whose coefficients change with time. You can specify a time-varying filter that changes once per frame, or once per sample. You can filter multiple channels with each filter, but you cannot apply different filters to each channel; all channels must be filtered with the same filter.
To specify a time-varying filter, you must do the following:
Setting the Coefficient Update Rate. When the input is frame based, the block updates time-varying filters once every input frame, or once for every sample in an input frame, depending on the Coefficient update rate parameter:
Though the following figure shows the block filtering one channel, the block can filter multiple channels. (The block can apply a single filter to multiple channels, but cannot apply a different filter to each channel.) To learn how to correctly specify vectors of time-varying filter coefficients, see Providing Filter Coefficient Vectors at Block Input Ports.
Figure 7-1: Options for Updating a Time-Varying Filter for a Frame-Based Input Signal
Providing Filter Coefficient Vectors at Block Input Ports. As illustrated in Figure 7-1, the filter coefficient vectors for filters that update once per frame are different from coefficient vectors for filters that update once per sample. See the following tables to meet the rate and length requirements of the filter coefficient vectors:
The output size, frame status, dimension, and data type always match those of the input signal that is filtered, not the vector of filter coefficients.
| Coefficient Update Rate |
How to Specify Filter Coefficient Vectors (Also see Figure 7-1) |
Length Requirements |
| Once per frame |
Each coefficient vector corresponds to one input frame, and represents one filter. Specify each vector as you would any static filter: [b0, b1, b2, ..., bn], [a0, a1, a2, ..., am], or [k1, k2, ..., kn] |
None |
| Once per sample |
Each coefficient vector corresponds to one input frame, but represents multiple filters of the same length: one filter for each sample in the current frame. To create such a vector, concatenate all the filters for each sample within the input frame. For instance, the following vector specifies length-2 numerator coefficients for each sample in a frame of three samples: where |
All filters must be the same length, L. The length of each filter coefficient vector must be L times the number of samples per frame in the input. (Each sample in the frame has one set of filter coefficients.) |
The time-varying filter coefficient vectors can be sample- or frame-based row or column vectors. The vector of filter coefficients must arrive at their input ports at the same times that the frames of input data arrive at their input port, as indicated in the following table.
| Input Signal |
Time-Varying Filter Coefficient Vectors |
Rate Requirements (Also see Figure 7-1) |
| Sample-based |
Sample-based |
Sample rates of input and filter coefficients must be equal |
| Sample-based |
Frame-based |
Input sample rate must equal filter coefficient frame rate |
| Frame-based |
Sample-based |
Input frame rate must equal filter coefficient sample rate |
| Frame-based |
Frame-based |
Frame rates of input and filter coefficients must be equal |
Removing the 1/a0 Term in the Filter Structure. If you know that the first denominator filter coefficient (a0) is always 1 for your time-varying filter, select the First denominator coefficient = 1, remove 1/a0 term in the structure parameter. Selecting this parameter reduces the number of computations the block must make to produce the output (the block omits the 1 / a0 term in the filter structure, as illustrated in the following figure). The block output is invalid if you select this parameter when the first denominator filter coefficient is not always 1 for your time-varying filter.

Specifying the SOS Matrix (Biquadratic Filter Coefficients)
The block does not support time-varying biquadratic direct form II transposed filters. To specify a static biquadratic direct form II transposed filter (also known as a second-order section or SOS direct form II transposed filter), you need to set the following parameters as indicated:
The SOS matrix is an M-by-6 matrix, where M is the number of sections in the second-order section filter. Each row of the SOS matrix contains the numerator and denominator coefficients (bik and aik) of the corresponding section in the filter. You can use the ss2sos and tf2sos functions from the Signal Processing Toolbox to convert a state-space or transfer-function description of your filter into the second-order section description used by this block.
| Note The block uses a value of 1 for the zero-delay denominator coefficients (a11 to a1M) regardless of the value specified in the SOS matrix (Mx6) parameter. |
Specifying Initial Conditions
By default, the block initializes the internal filter states to zero, which is equivalent to assuming past inputs and outputs are zero. You can optionally use the Initial conditions parameter to specify nonzero initial conditions for the filter delays.
To determine the number of initial condition values you must specify, and how to specify them, refer to Table 7-6, Valid Initial Conditions and Table 7-7, Number of Delay Elements (Filter States). The Initial conditions parameter may take one of four forms as described in the following table.
| Initial Condition |
Examples |
Description |
| Scalar |
5Each delay element for each channel is set to 5. |
The block initializes all delay elements in the filter to the scalar value. |
| Vector (for applying the same delay elements to each channel) |
For a filter with two delay elements: [d1 d2] 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:
|
| Vector or Matrix (for applying different delay elements to each channel) |
For a 3-channel input signal and a filter with two delay elements: [d1 d2 D1 D2 d1 d2] or ![]() |
Each vector or matrix element specifies a unique initial condition for a corresponding delay element in a corresponding channel:
|
| Empty matrix |
[ ] Each delay element for each channel is set to 0. |
The empty matrix, [], is equivalent to setting the Initial conditions parameter to the scalar value 0. |
The number of delay elements (filter states) per input channel depends on the filter structure, as indicated in the following table.
Example
You can open the following model by clicking here in the MATLAB Help browser (not in a Web browser). To build the model yourself, follow the step-by-step instructions in Implementing Predesigned Filters with the Digital Filter Block, which also provides a full explanation of the model.

Figure 7-2: Model Using the Digital Filter Block to Implement Filters
Figure 7-3: Vector Scope Display After Running the Model
Dialog Box
ss2sos and tf2sos functions from the Signal Processing Toolbox to check wether your SOS matrix is valid. For more on the requirements of the SOS matrix, see Specifying the SOS Matrix (Biquadratic Filter Coefficients). This parameter is visible only when the Coefficient source parameter is set to Dialog parameter(s) and the filter lends itself to specification with an SOS matrix. Tunable.1 / a0 term in the filter structure). The block output is invalid if you select this parameter when the first denominator filter coefficient is not always 1 for your time-varying filter. This parameter is visible only when the Coefficient source parameter is set to Input port(s). See Removing the 1/a0 Term in the Filter Structure for a diagram and details.Supported Data Types
To learn how to convert to the above data types in MATLAB and Simulink, see Supported Data Types and How to Convert to Them.
The output data type is the same as the data type of the filtered input signal (not necessarily the same as the data type of the filter coefficients).
See Also
| Digital Filter Design |
DSP Blockset |
| Filter Realization Wizard |
DSP Blockset |
fdatool |
Signal Processing Toolbox |
fvtool |
Signal Processing Toolbox |
sptool |
Signal Processing Toolbox |
| Difference | Digital Filter Design | ![]() |