Digital Filter

Filter each channel of input over time using static or time-varying digital filter implementations

Library

Filtering / Filter Designs

dsparch4

Description

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.

This block filters each channel of the input signal independently over time. The output frame status and dimensions 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 this block numerically match the outputs of the Digital Filter Design block and of the dfilt function in Signal Processing Toolbox software or Filter Design Toolbox software.

Sections of This Reference Page

Coefficient Source

The Digital Filter block can operate in three different modes. Select the mode in the Coefficient source group box. If you select

Supported Filter Structures

When you select Discrete-time filter object (DFILT), the following dfilt structures are supported:

When you select Dialog parameters or Input port(s), the list of filter structures offered in the Filter structure parameter depends on whether you set the Transfer function type to IIR (poles & zeros), IIR (all poles), or FIR (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.

Filter Structures and Filter Coefficients

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

  • Numerator coefficients vector [b0, b1, b2, ..., bn]

  • Denominator coefficients vector [a0, a1, a2, ..., am]

Biquadratic direct form I (SOS)

Biquadratic direct form I transposed (SOS)

Biquadratic direct form II (SOS)

Biquadratic direct form II transposed (SOS)

  • M-by-6 second-order section (SOS) matrix.

  • Scale values

See Specifying the SOS Matrix (Biquadratic Filter Coefficients).

IIR (all poles)

Direct form

Direct form transposed

Denominator coefficients vector [a0, a1, a2, ..., am]

Lattice AR

Reflection coefficients vector [k1, k2, ..., kn]

FIR (all zeros)

Direct form

Direct form symmetric

Direct form antisymmetric

Direct form transposed

Numerator coefficients vector [b0, b1, b2, ..., bn]

Lattice MA

Reflection coefficients vector [k1, k2, ..., kn]

Specifying Initial Conditions

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 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, see the following table on Valid Initial Conditions and Number of Delay Elements (Filter States). The Initial conditions parameter can take one of four forms as described in the following table.

Valid Initial Conditions

Initial ConditionExamplesDescription

Scalar

5

Each 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. 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 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

  • The delay elements for channel 1 are d1 and d2.

  • The delay elements for channel 2 are D1 and D2.

  • The delay elements for channel 3 are d1and d2.

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

  • The vector length must be equal to the product of the number of input channels and the number of delay elements in the filter (specified in the table Number of Delay Elements (Filter States)).

  • The matrix must have the same number of rows as the number of delay elements in the filter (specified in the table Number of Delay Elements (Filter States)), and must have one column for each channel of the input signal.

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.

Number of Delay Elements (Filter States)

Filter StructureNumber of Delay Elements per Channel

Direct form
Direct form transposed
Direct form symmetric
Direct form antisymmetric

#_of_filter_coeffs-1

Direct form I
Direct form I transposed

  • #_of_zeros-1

  • #_of_poles-1

Direct form II
Direct form II transposed

max(#_of_zeros, #_of_poles)-1

Biquadratic direct form I (SOS)
Biquadratic direct form I transposed (SOS)
Biquadratic direct form II (SOS)
Biquadratic direct form II transposed (SOS)

2 * #_of_filter_sections

Lattice AR
Lattice MA

#_of_reflection_coeffs

State Logging

Simulink enables you to log the states in your model to the MATLAB® workspace. The following table indicates which filter structures of the Digital Filter block support the Simulink state logging feature. See States in the Simulink User's Guide documentation for more information.

Transfer Function TypeFilter StructureState Logging Supported
IIR (poles & zeros)Direct form I

No

Direct form I transposed

Yes

Direct form II

No

Direct form II transposed

Yes

Biquadratic direct form I (SOS)

Yes

Biquadratic direct form I transposed (SOS)

Yes

Biquadratic direct form II (SOS)

Yes

Biquadratic direct form II transposed (SOS)

Yes

IIR (all poles)Direct form

No

Direct form transposed

Yes

Lattice AR

Yes

FIR (all zeros)Direct form

No

Direct form symmetric

No

Direct form antisymmetric

No

Direct form transposed

Yes

Lattice MA

Yes

Fixed-Point Data Types

All structures supported by the Digital Filter block support fixed-point data types. You can specify intermediate fixed-point data types for quantities such as the coefficients, accumulator, and product output for each filter structure. See Filter Structure Diagrams for diagrams depicting the use of these intermediate fixed-point data types in each filter structure.

Dialog Box

Different items appear on the Digital Filter block dialog depending on whether you select Dialog parameters, Input port(s), or Discrete-time filter object (DFILT) in the Coefficient source group box. See the following sections for details:

Specify Filter Characteristics in Dialog and/or Through Input Ports

The Main pane of the Digital Filter block dialog appears as follows when Dialog parameters is specified in the Coefficient source group box. The parameters below can appear when Dialog parameters or Input port(s) is selected, as noted.

Transfer function type

Select the type of transfer function of the filter; IIR (poles & zeros), IIR (all poles), or FIR (all zeros). See Supported Filter Structures for more information.

Filter structure

Select the filter structure. The selection of available structures varies depending the setting of the Transfer function type parameter. See Supported Filter Structures for more information.

Numerator coefficients

Specify the vector of numerator coefficients of the filter's transfer function.

This parameter is only visible when Dialog parameters is selected and when the selected filter structure lends itself to specification with numerator coefficients. Tunable.

Denominator coefficients

Specify the vector of denominator coefficients of the filter's transfer function.

This parameter is only visible when Dialog parameters is selected and when the selected filter structure lends itself to specification with denominator coefficients. Tunable.

Reflection coefficients

Specify the vector of reflection coefficients of the filter's transfer function.

This parameter is only visible when Dialog parameters is selected and when the selected filter structure lends itself to specification with reflection coefficients. Tunable.

SOS matrix (Mx6)

Specify an M-by-6 SOS matrix containing coefficients of a second-order section (SOS) filter, where M is the number of sections. You can use the ss2sos and tf2sos functions from Signal Processing Toolbox software to check whether 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 only visible when Dialog parameters is selected and when the selected filter structure is biquadratic. Tunable.

Scale values

Specify the scale values to be applied before and after each section of a biquadratic filter.

This parameter is only visible when Dialog parameters is selected and when the selected filter structure is biquadratic. Tunable.

First denominator coefficient = 1, remove a0 term in the structure

Select this parameter to reduce the number of computations the block must make to produce the output by omitting the 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 only enabled when the Input port(s) is selected and when the selected filter structure lends itself to this specification. See Removing the a0 Term in the Filter Structure for a diagram and details.

Coefficient update rate

Specify how often the block updates time-varying filters; once per sample or once per frame. This parameter only affects the output when the input signal is frame based.

This parameter is only visible when the Input port(s) is selected and when the selected filter structure lends itself to this specification. For more information, see Specifying Time-Varying Filters.

Initial conditions

Specify the initial conditions of the filter states. To learn how to specify initial conditions, see Specifying Initial Conditions.

Initial conditions on zeros side

(Not shown in dialog above.) Specify the initial conditions for the filter states on the side of the filter structure with the zeros (b0, b1,b2, ...); see the diagram below.

This parameter is enabled only when the filter has both poles and zeros, and when you select a structure such as direct form I, which has separate filter states corresponding to the poles (ak) and zeros (bk). To learn how to specify initial conditions, see Specifying Initial Conditions.

Initial conditions on poles side

(Not shown in dialog above). Specify the initial conditions for the filter states on the side of the filter structure with the poles (a0, a1,a2, ...); see the diagram below.

This parameter is enabled only when the filter has both poles and zeros, and when you select a structure such as direct form I, which has separate filter states corresponding to the poles (ak) and zeros (bk). To learn how to specify initial conditions, see Specifying Initial Conditions.

View filter response

This button opens the Filter Visualization Tool (fvtool) from the Signal Processing Toolbox product and displays the filter response of the filter defined by the block. For more information on FVTool, see the Signal Processing Toolbox documentation.

The Fixed point pane of the Digital Filter block dialog appears as follows when Dialog parameters is specified in the Coefficient source group box. The parameters below can appear when Dialog parameters or Input port(s) is selected, depending on the filter structure and whether the coefficients are being entered via ports or on the block mask.

Rounding mode

Select the rounding mode for fixed-point operations. The filter coefficients do not obey this parameter; they always round to Nearest.

Overflow mode

Select the overflow mode for fixed-point operations. The filter coefficients do not obey this parameter; they are always saturated.

Section I/O

Choose how you specify the word length and the fraction length of the fixed-point data type going into and coming out of each section of a biquadratic filter. See Filter Structure Diagrams for illustrations depicting the use of the section I/O data type in this block.

This parameter is only visible when the selected filter structure is biquadratic:

Tap sum

Choose how you specify the word length and the fraction length of the tap sum data type of a direct form symmetric or direct form antisymmetric filter. See Filter Structure Diagrams for illustrations depicting the use of the tap sum data type in this block.

This parameter is only visible when the selected filter structure is either Direct form symmetric or Direct form antisymmetric:

Multiplicand

Choose how you specify the word length and the fraction length of the multiplicand data type of a direct form I transposed or biquadratic direct form I transposed filter. See Filter Structure Diagrams for illustrations depicting the use of the multiplicand data type in this block.

This parameter is only visible when the selected filter structure is either Direct form I transposed or Biquad direct form I transposed (SOS):

Coefficients

Choose how you specify the word length and the fraction length of the filter coefficients (numerator and/or denominator). See Filter Structure Diagrams for illustrations depicting the use of the coefficient data types in this block:

Product output

Use this parameter to specify how you would like to designate the product output word and fraction lengths. See Filter Structure Diagrams and Multiplication Data Types for illustrations depicting the use of the product output data type in this block:

Accumulator

Use this parameter to specify how you would like to designate the accumulator word and fraction lengths. See Filter Structure Diagrams and Multiplication Data Types for illustrations depicting the use of the accumulator data type in this block:

State

Use this parameter to specify how you would like to designate the state word and fraction lengths. See Filter Structure Diagrams for illustrations depicting the use of the state data type in this block.

This parameter is not visible for direct form and direct form I filter structures.

Output

Choose how you specify the output word length and fraction length:

Lock scaling against changes by the autoscaling tool

Select this parameter to prevent any fixed-point scaling you specify in this block mask from being overridden by the autoscaling tool in the Fixed-Point Tool.

Specify Discrete-Time Filter Object

The Main pane of the Digital Filter block dialog appears as follows when Discrete-time filter object (DFILT) is specified in the Coefficient source group box.

Filter

Specify the discrete-time filter object (dfilt) that you would like the block to implement. You can do this in one of three ways:

For more information on creating dfilt objects, see the dfilt function reference page in the Signal Processing Toolbox documentation or the Filter Design Toolbox documentation.

View filter response

This button opens the Filter Visualization Tool (fvtool) from the Signal Processing Toolbox product and displays the filter response of the dfilt object specified in the Filter parameter. For more information on FVTool, see the Signal Processing Toolbox documentation.

The Fixed-point pane of the Digital Filter block dialog appears as follows when Discrete-time filter object (DFILT) is specified in the Coefficient source group box.

The fixed-point settings of the filter object specified on the Main pane are displayed on the Fixed-point pane. You cannot change these settings directly on the block mask. To change the fixed-point settings you must edit the filter object directly.

For more information on discrete-time filter objects, see the dfilt function reference page in the Signal Processing Toolbox documentation or the Filter Design Toolbox documentation.

Filter Structure Diagrams

The diagrams in the following sections show the filter structures supported by the Digital Filter block. They also show the data types used in the filter structures for fixed-point signals. You can set the coefficient, output, accumulator, product output, and state data types shown in these diagrams in the block dialog. This is discussed in Dialog Box.

IIR direct form I

The following constraints are applicable when processing a fixed-point signal with this filter structure:

IIR direct form I transposed

The following constraints are applicable when processing a fixed-point signal with this filter structure:

IIR direct form II

The following constraints are applicable when processing a fixed-point signal with this filter structure:

IIR direct form II transposed

The following constraints are applicable when processing a fixed-point signal with this filter structure:

IIR biquadratic direct form I

The following constraints are applicable when processing a fixed-point signal with this filter structure:

The following diagram shows the data types for one section of the filter.

The following diagram shows the data types between filter sections.

IIR biquadratic direct form I transposed

The following constraints are applicable when processing a fixed-point signal with this filter structure:

The following diagram shows the data types for one section of the filter.

The following diagram shows the data types between filter sections.

IIR biquadratic direct form II

The following constraints are applicable when processing a fixed-point signal with this filter structure:

The following diagram shows the data types for one section of the filter.

The following diagram shows the data types between filter sections.

IIR biquadratic direct form II transposed

The following constraints are applicable when processing a fixed-point signal with this filter structure:

The following diagram shows the data types for one section of the filter.

The following diagram shows the data types between filter sections.

IIR (all poles) direct form

The following constraints are applicable when processing a fixed-point signal with this filter structure:

IIR (all poles) direct form transposed

The following constraints are applicable when processing a fixed-point signal with this filter structure:

IIR (all poles) direct form lattice AR

The following constraints are applicable when processing a fixed-point signal with this filter structure:

FIR (all zeros) direct form

The following constraints are applicable when processing a fixed-point signal with this filter structure:

FIR (all zeros) direct form symmetric

The following constraints are applicable when processing a fixed-point signal with this filter structure:

FIR (all zeros) direct form antisymmetric

The following constraints are applicable when processing a fixed-point signal with this filter structure:

FIR (all zeros) direct form transposed

The following constraints are applicable when processing a fixed-point signal with this filter structure:

FIR (all zeros) lattice MA

The following constraints are applicable when processing a fixed-point signal with this filter structure:

Supported Data Types

See Also

Digital Filter DesignSignal Processing Blockset
Filter Realization WizardSignal Processing Blockset
dfiltSignal Processing Toolbox
fdatoolSignal Processing Toolbox
fvtoolSignal Processing Toolbox
sptoolSignal Processing Toolbox

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS