# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

## Library

Filtering / Filter Implementations

`dsparch4`

## Description

The Biquad Filter block independently filters each channel of the input signal with the specified biquadratic IIR filter. When you specify the filter coefficients in the dialog box, the block implements static filters with fixed coefficients. When you provide the filter coefficients through an input port, you can tune the coefficients during simulation.

The block filters an M-by-N input matrix as follows:

• When you set the Input processing parameter to `Columns as channels (frame based)`, the block treats each column as a separate channel. In this mode, the block creates M instances of the same filter, each with its own independent state buffer. Each of the M filters process N input samples at every Simulink® time step.

• When you set the Input processing parameter to `Elements as channels (sample based)`, the block treats each element as a separate channel. In this mode, the block creates M*N instances of the same filter, each with its own independent state buffer. Each filter processes one input sample at every Simulink time step.

This block supports variable-size input. It means that while the block is simulating, the frame size (number of rows) can change. The output dimensions always equal the dimensions of the input signal. The outputs of this block numerically match the outputs of the `dsp.BiquadFilter` System object™.

### Coefficient Source and Filter Structures

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

• Dialog parameters — Enter information about the filter such as structure and coefficients in the block mask. In this mode, you can choose the following filter structures in the Filter structure parameter:

• `Direct form I`

• `Direct form I transposed`

• `Direct form II`

• `Direct form II transposed`

• Input port(s) — Enter information about the filter structure in the block mask using the Filter structure parameter. The filter coefficients come into the block via input ports. The following additional ports appear on the block icon:

• `Num` — Specify numerator coefficients

• `Den` — Specify denominator coefficients

• `g` — Specify scale values

`Num` must be a 3–by–N numeric matrix, `Den` must be a 2–by–N numeric matrix, and `g` must be a 1–by–(N+1) numeric vector, where N is the number of biquad filter sections. The object assumes the first denominator coefficients of each section to be 1. This configuration is applicable when the `SOSMatrixSource` property is ‘Input port’ and the `ScaleValuesInputPort` property is true. The reason you would need to specify `Num` and `Den` instead of the `SOSMatrix`, is that in Fixed-Point operation, the numerators, and denominators can have different fraction lengths. Therefore, there is a need to be able to pass the data of the numerator with a fixed-point type different from that of the denominator.

• Filter object — Specify the filter using a `dsp.BiquadFilter` System object.

### Specifying the SOS Matrix and Scale Values

The SOS matrix (Mx6) 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.

`$\left[\begin{array}{cccccc}{b}_{01}& {b}_{11}& {b}_{21}& {a}_{01}& {a}_{11}& {a}_{21}\\ {b}_{02}& {b}_{12}& {b}_{22}& {a}_{02}& {a}_{12}& {a}_{22}\\ ⋮& ⋮& ⋮& ⋮& ⋮& ⋮\\ {b}_{0M}& {b}_{1M}& {b}_{2M}& {a}_{0M}& {a}_{1M}& {a}_{2M}\end{array}\right]$`

`ss2sos` and `tf2sos` functions from Signal Processing Toolbox™ convert a state-space or transfer function description of your filter into the second-order section description used by this block.

The Scale values parameter specifies the scale values the block uses between each SOS section. You can specify a real-valued scalar or a vector of length M+`1`.

• If you enter a scalar, the value specifies the gain value before the first section of the second-order filter. The rest of the gain values default to `1`.

• If you enter a vector of M+1 values, each value specifies a separate section of the filter. For example, the first element is the first gain value, the second element is the second gain value, and so on.

Select the Optimize unity scale values check box to optimize your simulation when one or more scale values equal 1. Selecting this option removes the unity gains so that the values are treated like Simulink lines or wires. In some fixed-point cases, when there are unity scale values, selecting this parameter also omits certain casts. Refer to Filter Structure Diagrams for more information.

### Specifying Initial Conditions

The Biquad Filter block initializes the internal filter states to zero by default. Optionally, use the Initial conditions or Initial conditions on zeros side and Initial conditions on poles side parameters to specify nonzero initial states for the filter delays.

To determine the number of initial conditions you must specify and how to specify them, see the following table on valid initial conditions.

Valid Initial Conditions

Initial ConditionDescription

Scalar

The block initializes all delay elements in the filter to the scalar value.

Vector or matrix
(for applying different delay elements to each channel)

Each vector or matrix element specifies a unique initial condition for a corresponding delay element in a corresponding channel. Where M is the number of sections and N is the number of input channels:

• The vector length must equal the number of delay elements in the filter, M*2.

• The matrix must have the same number of rows as the number of delay elements in the filter (M*2)*N. The matrix must also have one column for each channel of the input signal.

### Fixed-Point Data Types

See the Filter Structure Diagrams section for diagrams showing the data types the biquad filter block uses when processing fixed-point signals.

## Examples

Open an example model by typing `ex_biquad_filter_ref` at the MATLAB® command line.

## Dialog Box

### Coefficient Source

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

• Dialog parameters — Enter information about the filter such as structure and coefficients in the block mask. In this mode, you can choose the following filter structures in the Filter structure parameter:

• `Direct form I`

• `Direct form I transposed`

• `Direct form II`

• `Direct form II transposed`

• Input port(s) — Enter information about the filter structure in the block mask using the Filter structure parameter. The filter coefficients come into the block via input ports. The following additional ports appear on the block icon:

• `Num` — Specify numerator coefficients

• `Den` — Specify denominator coefficients

• `g` — Specify scale values

`Num` must be a 3–by–N numeric matrix, `Den` must be a 2–by–N numeric matrix, and `g` must be a 1–by–(N+1) numeric vector, where N is the number of biquad filter sections. The object assumes the first denominator coefficients of each section to be 1. This configuration is applicable when the `SOSMatrixSource` property is ‘Input port’ and the `ScaleValuesInputPort` property is true. The reason you would need to specify `Num` and `Den` instead of the `SOSMatrix`, is that in Fixed-Point operation, the numerators, and denominators can have different fraction lengths. Therefore, there is a need to be able to pass the data of the numerator with a fixed-point type different from that of the denominator.

• Filter object — Specify the filter using a `dsp.BiquadFilter` System object.

## Filter Structure Diagrams

The diagrams in the following sections show the filter structures supported by the Biquad Filter block. They also show the data types used in the filter structures for fixed-point signals. You can set the data types shown in these diagrams in the block dialog box. This is discussed in Dialog Box.

### Direct Form I

The following diagram shows the data types for one section of the filter for fixed-point signals.

The following diagrams show the fixed-point data types between filter sections.

When the data is not optimized:

When you select Optimize unity scale values and scale values equal 1:

### Direct Form I Transposed

The following diagram shows the data types for one section of the filter for fixed-point signals.

The dashed casts are omitted when Optimize unity scale values is selected and scale values equal one.

The following diagrams show the fixed-point data types between filter sections.

When the data is not optimized:

When you select Optimize unity scale values and scale values equal 1:

### Direct Form II

The following diagram shows the data types for one section of the filter for fixed-point signals.

The dashed casts are omitted when Optimize unity scale values is selected and scale values equal one.

The following diagrams show the fixed-point data types between filter sections.

When the data is not optimized:

When you select Optimize unity scale values and scale values equal 1:

### Direct Form II Transposed

The following diagram shows the data types for one section of the filter for fixed-point signals.

The following diagrams show the fixed-point data types between filter sections.

When the data is not optimized:

When you select Optimize unity scale values and scale values equal 1:

## HDL Code Generation

This block supports HDL code generation using HDL Coder™. HDL Coder provides additional configuration options that affect HDL implementation and synthesized logic. For more information on implementations, properties, and restrictions for HDL code generation, see Biquad Filter.

## Supported Data Types

PortSupported Data Types

Input

• Double-precision floating point

• Single-precision floating point

• Fixed point (signed only)

• 8-, 16-, and 32-bit signed integers

Output

• Double-precision floating point

• Single-precision floating point

• Fixed point (signed only)

• 8-, 16-, and 32-bit signed integers