# dsp.BiquadFilter

IIR filter using biquadratic structures

## Description

The `dsp.BiquadFilter`

object implements a cascade of biquadratic
sections, where the coefficients for each section are supplied by a separate row of an
*N*-by-6 second-order sections (SOS) matrix. Each row of the SOS
matrix contains the numerator and denominator coefficients of the corresponding section
of the filter. The resulting filter can be applied to a vector or matrix input, where
each column represents a channel of data that is processed independently.

To implement an IIR filter structure using biquadratic or SOS:

Create the

`dsp.BiquadFilter`

object and set its properties.Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?

## Creation

### Syntax

### Description

returns a
biquadratic IIR (SOS) filter System object™, `biquad`

= dsp.BiquadFilter`biquad`

, which independently filters each
channel (column) of the input over time using the SOS section ```
[1 0.3
0.4 1 0.1 0.2]
```

with a direct-form II transposed structure.

`biquad = dsp.BiquadFilter(sosmatrix,scalevalues)`

returns
a biquadratic filter object, with the `SOSMatrix`

property
set to `sosmatrix`

and the `ScaleValues`

property set to `scalevalues`

.

`biquad = dsp.BiquadFilter(`

returns a biquadratic filter object, `Name,Value`

)`biquad`

, with each
property set to the specified value.

## Properties

Unless otherwise indicated, properties are *nontunable*, which means you cannot change their
values after calling the object. Objects lock when you call them, and the
`release`

function unlocks them.

If a property is *tunable*, you can change its value at
any time.

For more information on changing property values, see System Design in MATLAB Using System Objects.

`Structure`

— Filter structure

`'Direct form II transposed'`

(default) | `'Direct form I'`

| `'Direct form I transposed'`

| `'Direct form II'`

Specify the filter structure as `'Direct form I'`

,
`'Direct form I transposed'`

, ```
'Direct form
II'
```

, `'Direct form II transposed'`

.

`SOSMatrixSource`

— SOS matrix source

`'Property'`

(default) | `'Input port'`

Specify the source of the SOS matrix as `'Property'`

or
`'Input port'`

.

`SOSMatrix`

— SOS matrix

`[1 0.3 0.4 1 0.1 0.2]`

(default) | *N*-by-6 matrix

Specify the second-order section (SOS) matrix as an N-by-6 matrix, where N
is the number of sections in the filter. Each row of the SOS matrix contains
the numerator and denominator coefficients of the corresponding section of
the filter. The system function, *H(z)*, of a biquad filter is:

$$H(z)=\frac{{\displaystyle \sum _{k=0}^{2}{b}_{k}}{z}^{-k}}{1-{\displaystyle \sum _{l=1}^{2}{a}_{l}}{z}^{-l}}$$

The coefficients are ordered in the rows of the SOS
matrix as (b_{0},
b_{1,}b_{2,}1,
–a_{1},
–a_{2}). You can use coefficients of real or complex values. This
property applies only when you set the `SOSMatrixSource`

property to `Property`

. The leading denominator coefficient
of the biquad filter, a_{0}, equals 1 for each filter section, regardless of the
specified value.

**Data Types: **`single`

| `double`

| `int8`

| `int16`

| `int32`

| `int64`

| `uint8`

| `uint16`

| `uint32`

| `uint64`

| `fi`

`ScaleValues`

— Scale values for each biquad section

`1`

(default) | scalar | vector

Specify the scale values to apply before and after each section of a
biquad filter. `ScaleValues`

must be either
a scalar or a vector of length `N+1`

, where
`N`

is the number of sections. If you set this property
to a scalar, the scalar value is used as the gain value only before the
first filter section. The remaining gain values are set to
`1`

. If you set this property to a vector of
`N+1`

values, each value is used for a separate section
of the filter.

#### Dependencies

This property applies only when you set the
`SOSMatrixSource`

property to
`Property`

.

**Data Types: **`single`

| `double`

| `int8`

| `int16`

| `int32`

| `int64`

| `uint8`

| `uint16`

| `uint32`

| `uint64`

`InitialConditions`

— Initial conditions for direct form II structures

`0`

(default) | scalar | vector | matrix

Specify the initial conditions of the filter states when the
`Structure`

property is one of | ```
Direct form
II
```

| `Direct form II transposed`

|. The
number of states or delay elements (zeros and poles) in a direct-form II
biquad filter equals twice the number of filter sections. You can specify
the initial conditions as a scalar, vector, or matrix.

When you specify a scalar value, the biquad filter initializes all delay elements in the filter to that value. When you specify a vector of length equal to the number of delay elements in the filter, each vector element specifies a unique initial condition for the corresponding delay element.

The biquad filter applies the same vector of initial conditions to each channel of the input signal. When you specify a vector of length equal to the product of the number of input channels and the number of delay elements in the filter, each element specifies a unique initial condition for the corresponding delay element in the corresponding channel. When you specify a matrix with the same number of rows as the number of delay elements in the filter, and one column for each channel of the input signal, each element specifies a unique initial condition for the corresponding delay element in the corresponding channel.

#### Dependencies

This property applies only when you set the
`Structure`

property to one of ```
Direct
form II
```

or ```
Direct form II
transposed
```

.

**Data Types: **`single`

| `double`

| `int8`

| `int16`

| `int32`

| `int64`

| `uint8`

| `uint16`

| `uint32`

| `uint64`

`NumeratorInitialConditions`

— Initial conditions on zeros side

`0`

(default) | scalar | vector | matrix

Specify the initial conditions of the filter states on the side of the filter structure with the zeros. The number of states or delay elements in the numerator of a direct-form I biquad filter equals twice the number of filter sections. You can specify the initial conditions as a scalar, vector, or matrix. When you specify a scalar, the biquad filter initializes all delay elements on the zeros side in the filter to that value. When you specify a vector of length equal to the number of delay elements on the zeros side in the filter, each vector element specifies a unique initial condition for the corresponding delay element on the zeros side.

The biquad filter applies the same vector of initial conditions to each channel of the input signal. When you specify a vector of length equal to the product of the number of input channels and the number of delay elements on the zeros side in the filter, each element specifies a unique initial condition for the corresponding delay element on the zeros side in the corresponding channel. When you specify a matrix with the same number of rows as the number of delay elements on the zeros side in the filter, and one column for each channel of the input signal, each element specifies a unique initial condition for the corresponding delay element on the zeros side in the corresponding channel.

#### Dependencies

This property applies only when you set the
`Structure`

property to one of ```
Direct
form I
```

or ```
Direct form I
transposed
```

.

**Data Types: **`single`

| `double`

| `int8`

| `int16`

| `int32`

| `int64`

| `uint8`

| `uint16`

| `uint32`

| `uint64`

`DenominatorInitialConditions`

— Initial conditions on poles side

`0`

(default) | scalar | vector | matrix

Specify the initial conditions of the filter states on the side of the filter structure with the poles. The number of denominator states, or delay elements, in a direct-form I (noncanonic) biquad filter equals twice the number of filter sections. You can specify the initial conditions as a scalar, vector, or matrix. When you specify a scalar, the biquad filter initializes all delay elements on the poles side of the filter to that value. When you specify a vector of length equal to the number of delay elements on the poles side in the filter, each vector element specifies a unique initial condition for the corresponding delay element on the poles side.

The object applies the same vector of initial conditions to each channel of the input signal. When you specify a vector of length equal to the product of the number of input channels and the number of delay elements on the poles side in the filter, each element specifies a unique initial condition for the corresponding delay element on the poles side in the corresponding channel. When you specify a matrix with the same number of rows as the number of delay elements on the poles side in the filter, and one column for each channel of the input signal, each element specifies a unique initial condition for the corresponding delay element on the poles side in the corresponding channel.

#### Dependencies

This property only applies when you set the
`Structure`

property to one of ```
Direct
form I
```

or ```
Direct form I
transposed
```

.

**Data Types: **`single`

| `double`

| `int8`

| `int16`

| `int32`

| `int64`

| `uint8`

| `uint16`

| `uint32`

| `uint64`

`OptimizeUnityScaleValues`

— Optimize unity scale values

`true`

(default) | `false`

When this Boolean property is set to `true`

, the biquad
filter removes all unity scale gain computations. This reduces the number of
computations and increases the fixed-point accuracy.

#### Dependencies

This property applies only when you set the
`SOSMatrixSource`

property to
`Property`

.

`ScaleValuesInputPort`

— How to specify scale values

`true`

(default) | `false`

Select how to specify scale values. By default, this property is
`true`

, and the scale values are specified via the
input port. When this property is `false`

, all scale values
are 1.

#### Dependencies

This property applies only when the
`SOSMatrixSource`

property is ```
Input
port
```

.

### Fixed-Point Properties

`RoundingMethod`

— Rounding method for fixed-point operations

`Floor`

(default) | `Ceiling`

| `Convergent`

| `Nearest`

| `Round`

| `Simplest`

| `Zero`

Specify the rounding method.

`OverflowAction`

— Overflow action for fixed-point operations

`Wrap`

(default) | `Saturate`

Specify the overflow action as one of `Wrap`

or
`Saturate`

.

`MultiplicandDataType`

— Multiplicand word and fraction lengths

`Same as output`

(default) | `Custom`

Specify the multiplicand fixed-point data type as one of ```
Same
as output
```

or `Custom`

.

#### Dependencies

This property applies only when you set the
`Structure`

property to ```
Direct form
I transposed
```

.

`CustomMultiplicandDataType`

— Custom multiplicand word and fraction lengths

`numerictype([],32,30)`

(default) | numerictype

Specify the multiplicand fixed-point type as a scaled `numerictype`

(Fixed-Point Designer) object
with a `Signedness`

of
`Auto`

.

#### Dependencies

This property applies only when you set the
`MultiplicandDataType`

property to
`Custom`

.

`SectionInputDataType`

— Section input word and fraction lengths

`Same as input`

(default) | `Custom`

Specify the section input fixed-point data type as either
`Same as input`

or
`Custom`

.

`CustomSectionInputDataType`

— Custom section input word and fraction lengths

`numerictype([],16,15)`

(default) | numerictype

Specify the section input fixed-point type as a scaled `numerictype`

(Fixed-Point Designer) object
with a `Signedness`

of
`Auto`

.

#### Dependencies

This property applies only when you set the
`SectionInputDataType`

property to
`Custom`

.

`SectionOutputDataType`

— Section output word and fraction lengths

`Same as section input`

(default) | `Custom`

Specify the section output fixed-point data type as either
`Same as section input`

or
`Custom`

.

`CustomSectionOutputDataType`

— Custom section output word and fraction lengths

`numerictype([],16,15)`

(default) | numerictype

Specify the section output fixed-point type as a signed, scaled
`numerictype`

(Fixed-Point Designer) object
with a `Signedness`

of
`Auto`

.

#### Dependencies

This property applies only when you set the
`SectionOutputDataType`

property to
`Custom`

.

`NumeratorCoefficientsDataType`

— Numerator coefficients word and fraction lengths

`Same word length as input`

(default) | `Custom`

Specify the numerator coefficients fixed-point data type as
`Same word length as input`

or
`Custom`

. Setting this property also sets the
`DenominatorCoefficientsDataType`

and
`ScaleValuesDataType`

properties to the same
value.

#### Dependencies

This property applies only when you set the
`SOSMatrixSource`

property to
`Property`

.

`CustomNumeratorCoefficientsDataType`

— Custom numerator coefficients word and fraction lengths

`numerictype([],16,15)`

(default) | numerictype

Specify the numerator coefficients fixed-point type as a `numerictype`

(Fixed-Point Designer) object
with a `Signedness`

of `Auto`

. The
word length of the
`CustomNumeratorCoefficientsDataType`

,
`CustomDenominatorCoefficientsDataType`

, and
`CustomScaleValuesDataType`

properties must be
the same.

#### Dependencies

This property applies only when you set the
`SOSMatrixSource`

property to
`Property`

and the
`NumeratorCoefficientsDataType`

property to
`Custom`

.

`DenominatorCoefficientsDataType`

— Denominator coefficients word and fraction lengths

`Same word length as input`

(default) | `Custom`

Specify the denominator coefficients fixed-point data type as
`Same word length as input`

or
`Custom`

. Setting this property also sets the
`NumeratorCoefficientsDataType`

and
`ScaleValuesDataType`

properties to the same
value.

#### Dependencies

This property applies only when you set the
`SOSMatrixSource`

property to
`Property`

.

`CustomDenominatorCoefficientsDataType`

— Custom denominator coefficients word and fraction lengths

`numerictype([],16,15)`

(default) | numerictype

Specify the denominator coefficients fixed-point type as a `numerictype`

(Fixed-Point Designer) object
with a `Signedness`

of `Auto`

. The
`CustomNumeratorCoefficientsDataType`

,
`CustomDenominatorCoefficientsDataType`

, and
`CustomScaleValuesDataType`

properties must have
the same word lengths.

#### Dependencies

This property applies only when you set the
`SOSMatrixSource`

property to
`Property`

and the
`DenominatorCoefficientsDataType`

property to
`Custom`

.

`ScaleValuesDataType`

— Scale values word and fraction lengths

`Same word length as input`

(default) | `Custom`

Specify the scale values fixed-point data type as ```
Same word
length as input
```

or `Custom`

. Setting this
property also sets the
`NumeratorCoefficientsDataType`

and
`DenominatorCoefficientsDataType`

properties to
the same value.

#### Dependencies

This property applies only when you set the
`SOSMatrixSource`

property to
`Property`

.

`CustomScaleValuesDataType`

— Custom scale values word and fraction lengths

`numerictype([],16,15)`

(default) | numerictype

Specify the scale values fixed-point type as a `numerictype`

(Fixed-Point Designer) object
with a `Signedness`

of `Auto`

. The
`CustomNumeratorCoefficientsDataType`

,
`CustomDenominatorCoefficientsDataType`

, and
`CustomScaleValuesDataType`

properties must have
the same word lengths.

#### Dependencies

This property applies only when you set the
`SOSMatrixSource`

property to
`Property`

and the
`ScaleValuesDataType`

property to
`Custom`

.

`NumeratorProductDataType`

— Numerator product word and fraction lengths

`Same as input`

(default) | `Custom`

| `Full precision`

Specify the mode to determine the numerator product fixed-point data type as:

`Same as input`

(default) — The numerator product word and fraction lengths are same as that of the input.`Custom`

— Enables the`CustomNumeratorProductDataType`

property, which you can use to specify the custom numerator product data type. Specify the data type as a`numerictype`

object.`Full precision`

— Use full-precision rules to specify the data type. These rules provide the most accurate fixed-point numerics. The rules prevent quantization from occurring within the object. Bits are added, as needed, so that no roundoff or overflow occurs. For more information, see Full Precision for Fixed-Point System Objects.

Setting this property also sets the
`DenominatorProductDataType`

property to the same
value.

`CustomNumeratorProductDataType`

— Custom numerator product word and fraction lengths

`numerictype([],32,30)`

(default) | numerictype

Specify the product fixed-point type as a scaled `numerictype`

(Fixed-Point Designer) object
with a `Signedness`

of `Auto`

. The
`CustomNumeratorProductDataType`

and
`CustomDenominatorProductDataType`

properties
must have the same word lengths.

#### Dependencies

This property applies only when you set the
`NumeratorProductDataType`

property to
`Custom`

.

`DenominatorProductDataType`

— Denominator product word and fraction lengths

`Same as input`

(default) | `Custom`

| `Full precision`

Specify the mode to determine the denominator product fixed-point data type as:

`Same as input`

(default) — The denominator product word and fraction lengths are same as that of the input.`Custom`

— Enables the`CustomDenominatorProductDataType`

property, which you can use to specify the custom denominator product data type. Specify the data type as a`numerictype`

object.`Full precision`

— Use full-precision rules to specify the data type. These rules provide the most accurate fixed-point numerics. The rules prevent quantization from occurring within the object. Bits are added, as needed, so that no roundoff or overflow occurs. For more information, see Full Precision for Fixed-Point System Objects.

Setting this property also sets the
`NumeratorProductDataType`

property to the same
value.

`CustomDenominatorProductDataType`

— Custom denominator product word and fraction lengths

`numerictype([],32,30)`

(default) | numerictype

Specify the product fixed-point type as a scaled `numerictype`

(Fixed-Point Designer) object
with a `Signedness`

of `Auto`

. The
`CustomNumeratorProductDataType`

and
`CustomDenominatorProductDataType`

properties
must have the same word lengths.

#### Dependencies

This property applies only when you set the
`DenominatorProductDataType`

to
`Custom`

.

`NumeratorAccumulatorDataType`

— Numerator accumulator word and fraction lengths

`Same as product`

(default) | `Same as input`

| `Custom`

Specify the numerator accumulator fixed-point data type as
`Same as input`

, ```
Same as
product
```

, or `Custom`

. Setting this property
also sets the `DenominatorAccumulatorDataType`

property to the same value.

`CustomNumeratorAccumulatorDataType`

— Custom numerator accumulator word and fraction lengths

`numerictype([],32,30)`

(default) | numerictype

Specify the numerator accumulator fixed-point type as a scaled
`numerictype`

(Fixed-Point Designer) object
with a `Signedness`

of `Auto`

. The
`CustomNumeratorAccumulatorDataType`

and
`CustomDenominatorAccumulatorDataType`

properties
must have the same word lengths.

#### Dependencies

This property applies only when you set the
`NumeratorAccumulatorDataType`

property to
`Custom`

.

`DenominatorAccumulatorDataType`

— Denominator accumulator word and fraction lengths

`Same as product`

(default) | `Same as input`

| `Custom`

Specify the denominator accumulator fixed-point data type as
`Same as input`

, ```
Same as
product
```

, or `Custom`

. Setting this property
also sets the `NumeratorAccumulatorDataType`

property
to the same value.

`CustomDenominatorAccumulatorDataType`

— Custom denominator accumulator word and fraction lengths

`numerictype([],32,30)`

(default) | numerictype

Specify the denominator accumulator fixed-point type as a scaled
`numerictype`

(Fixed-Point Designer) object
with a `Signedness`

of `Auto`

. The
`CustomNumeratorAccumulatorDataType`

and
`CustomDenominatorAccumulatorDataType`

properties
must have the same word lengths.

#### Dependencies

This property applies only when you set the
`DenominatorAccumulatorDataType`

property to
`Custom`

.

`StateDataType`

— State word and fraction lengths

`Same as accumulator`

(default) | `Same as input`

| `Custom`

Specify the state fixed-point data type as ```
Same as
input
```

, `Same as accumulator`

, or
`Custom`

.

#### Dependencies

This property applies when you set the Structure property to
`Direct form II`

or ```
Direct form II
transposed
```

.

`CustomStateDataType`

— Custom state word and fraction lengths

`numerictype([],16,15)`

(default) | numerictype

Specify the state fixed-point type as a scaled `numerictype`

(Fixed-Point Designer) object
with a `Signedness`

of
`Auto`

.

#### Dependencies

This property applies only when you set the
`StateDataType`

property to
`Custom`

.

`NumeratorStateDataType`

— Numerator state word and fraction lengths

`Same as accumulator`

(default) | `Same as input`

| `Custom`

Specify the numerator state fixed-point data type as ```
Same as
input
```

, `Same as accumulator`

, or
`Custom`

. Setting this property also sets the
`DenominatorStateDataType`

property to the same
value.

#### Dependencies

This property applies only when you set the Structure property to
`Direct form I transposed`

.

`CustomNumeratorStateDataType`

— Custom numerator state word and fraction lengths

`numerictype([],16,15)`

(default) | numerictype

Specify the numerator state fixed-point type as a scaled `numerictype`

(Fixed-Point Designer) object
with a `Signedness`

of `Auto`

. The
`CustomNumeratorProductDataType`

and
`CustomDenominatorProductDataType`

properties
must have the same word lengths.

#### Dependencies

This property applies only when you set the
`StateDataType`

property to
`Custom`

.

`DenominatorStateDataType`

— Denominator state word and fraction lengths

`Same as accumulator`

(default) | `Same as input`

| `Custom`

Specify the denominator state fixed-point data type as ```
Same
as input
```

, `Same as accumulator`

, or
`Custom`

. Setting this property also sets the
`NumeratorStateDataType`

property to the same
value.

#### Dependencies

This property applies only when you set the Structure property to
`Direct form I transposed`

.

`CustomDenominatorStateDataType`

— Custom denominator state word and fraction lengths

`numerictype([],16,15)`

(default) | numerictype

Specify the denominator state fixed-point type as a scaled `numerictype`

(Fixed-Point Designer) object
with a `Signedness`

of `Auto`

. The
`CustomNumeratorStateDataType`

and
`CustomDenominatorStateDataType`

properties must
have the same word lengths.

#### Dependencies

This property applies only when you set the
`StateDataType`

property to
`Custom`

.

`OutputDataType`

— Output word and fraction lengths

`Same as accumulator`

(default) | `Same as input`

| `Custom`

Specify the output fixed-point data type as ```
Same as
input
```

, `Same as accumulator`

, or
`Custom`

.

`CustomOutputDataType`

— Custom output word and fraction lengths

`numerictype([],16,15)`

(default) | numerictype

Specify the output fixed-point type as a scaled `numerictype`

(Fixed-Point Designer) object
with a `Signedness`

of
`Auto`

.

#### Dependencies

This property applies only when you set the OutputDataType property to
`Custom`

.

## Usage

### Description

### Input Arguments

`x`

— Data input

vector | matrix

Data input, specified as a vector or a matrix. This object also accepts variable-size inputs. Once the object is locked, you can change the size of each input channel, but you cannot change the number of channels.

The data type of all the inputs must be the same. If the input is fixed-point, it must be signed fixed point with power-of-two slope and zero bias.

The complexity of `x`

, `num`

,
and `den`

must be the same.

**Data Types: **`single`

| `double`

| `int8`

| `int16`

| `int32`

| `int64`

| `fi`

**Complex Number Support: **Yes

`num`

— Numerator coefficients

3-by-*N* matrix

Numerator coefficients, specified as a 3-by-*N *
numeric matrix, where *N* is the number of biquad
filter sections. The complexity of `x`

,
`num`

, and `den`

must be the
same.

The data type of all the inputs must be the same. If
`num`

is fixed point, it must be signed fixed
point with power-of-two slope and zero bias.

#### Dependencies

This input applies only when you set `SOSMatrixSource`

property is ```
Input
port
```

.

**Data Types: **`single`

| `double`

| `int8`

| `int16`

| `int32`

| `int64`

| `fi`

**Complex Number Support: **Yes

`den`

— Denominator coefficients

2-by-*N* matrix

Denominator coefficients, specified as a 2-by-*N *
numeric matrix, where *N* is the number of biquad
filter sections. The object assumes that the first denominator
coefficient of each section is 1.

The data type of all the inputs must be the same. If
`den`

is fixed point, it must be signed fixed
point with power-of-two slope and zero bias.

The complexity of `x`

, `num`

,
and `den`

must be the same.

#### Dependencies

This input applies only when you set `SOSMatrixSource`

property is ```
Input
port
```

.

**Data Types: **`single`

| `double`

| `int8`

| `int16`

| `int32`

| `int64`

| `fi`

**Complex Number Support: **Yes

`g`

— Scale values

1-by-(*N *+1) vector

Scale values of the biquad filter, specified as a 1-by-(*N
*+1) numeric vector, where `N`

is the number
of biquad filter sections.

The data type of all the inputs must be the same. If
`g`

is fixed point, it must be signed fixed point
with power-of-two slope and zero bias.

#### Dependencies

This input applies when the `SOSMatrixSource`

property is ```
Input
Port
```

and the `ScaleValuesInputPort`

property is `true`

.

**Data Types: **`single`

| `double`

| `int8`

| `int16`

| `int32`

| `int64`

| `fi`

### Output Arguments

`y`

— Filtered output

vector | matrix

Filtered output, returned as a vector or a matrix. The size, data type, and complexity of the output signal matches that of the input signal.

**Data Types: **`single`

| `double`

| `int8`

| `int16`

| `int32`

| `int64`

| `fi`

**Complex Number Support: **Yes

## Object Functions

To use an object function, specify the
System object as the first input argument. For
example, to release system resources of a System object named `obj`

, use
this syntax:

release(obj)

### Specific to `dsp.BiquadFilter`

`freqz` | Frequency response of discrete-time filter System object |

`fvtool` | Visualize frequency response of DSP filters |

`impz` | Impulse response of discrete-time filter System object |

`info` | Information about filter System object |

`coeffs` | Returns the filter System object coefficients in a structure |

`cost` | Estimate cost of implementing filter System object |

`scale` | Scale second-order sections |

`scaleopts` | Create an options object for second-order section scaling |

`scalecheck` | Check scaling of biquadratic filter |

`cumsec` | Cumulative second-order section of the biquadratic filter |

`generatehdl` | Generate HDL code for quantized DSP filter (requires Filter Design HDL Coder) |

`tf` | Convert discrete-time filter System object to transfer function |

`reorder` | Reorder second-order sections of biquadratic filter System object |

## Examples

### Filter a Signal Using Biquadratic Filter

**Note**: If you are using R2016a or an earlier release, replace each call to the object with the equivalent step syntax. For example, `obj(x)`

becomes `step(obj,x)`

.

Use a fourth order, lowpass biquadratic filter object with a normalized cutoff frequency of 0.4 to filter high frequencies from an input signal. Display the result as a power spectrum using the Spectrum Analyzer.

t = (0:1000)'/8e3; xin = sin(2*pi*0.3e3*t)+sin(2*pi*3e3*t); % Input is 0.3 & % 3kHz sinusoids src = dsp.SignalSource(xin, 100); sink = dsp.SignalSink; [z,p,k] = ellip(4,1,60,.4); % Set up the filter [s,g] = zp2sos(z,p,k); biquad = dsp.BiquadFilter(s,g,'Structure','Direct form I'); sa = spectrumAnalyzer('SampleRate',8e3,... 'Method','welch',... 'PlotAsTwoSidedSpectrum',false,... 'OverlapPercent', 80,'SpectrumUnits','dBW',... 'YLimits', [-160 -10]); while ~isDone(src) input = src(); filteredOutput = biquad(input); sink(filteredOutput); sa(filteredOutput) end

```
filteredResult = sink.Buffer;
fvtool(biquad,'Fs',8000)
```

Design and apply a lowpass biquad filter System object using the `design`

function.

lpSpec = fdesign.lowpass('Fp,Fst,Ap,Ast',500,550,0.5,60,10000); lpfilter = design(lpSpec,'butter','systemobject',true)

lpfilter = dsp.BiquadFilter with properties: Structure: 'Direct form II' SOSMatrixSource: 'Property' SOSMatrix: [42x6 double] ScaleValues: [43x1 double] InitialConditions: 0 OptimizeUnityScaleValues: true Show all properties

fvtool(lpfilter);

### Linf-norm Scaling of a Biquad Filter

Demonstrate the Linf-norm scaling of a biquad filter using the `scale`

function.

Fs = 8000; Fcutoff = 2000; [z,p,k] = butter(10,Fcutoff/(Fs/2)); [s,g] = zp2sos(z,p,k); biquad = dsp.BiquadFilter('Structure', 'Direct form I', ... 'SOSMatrix', s,'ScaleValues', g); scale(biquad,'linf','scalevalueconstraint','none','maxscalevalue',2)

### Options for scaling SOS filter

Create an options scaling object that contains the scaling options settings you require.

EllipI = design(fdesign.lowpass('N,Fp,Ap,Ast',10,0.5,0.5,20),... 'ellip',... 'FilterStructure', 'df1sos',... 'SystemObject',true)

EllipI = dsp.BiquadFilter with properties: Structure: 'Direct form I' SOSMatrixSource: 'Property' SOSMatrix: [5x6 double] ScaleValues: [6x1 double] NumeratorInitialConditions: 0 DenominatorInitialConditions: 0 OptimizeUnityScaleValues: true Show all properties

opts = scaleopts(EllipI)

opts = sosReorder: 'auto' MaxNumerator: 2 NumeratorConstraint: 'none' OverflowMode: 'wrap' ScaleValueConstraint: 'unit' MaxScaleValue: 'Not used'

## More About

### Fixed Point

The following diagrams show the data types used in the `dsp.BiquadFilter`

object when the input is fixed-point. For each
filter structure the object supports, the data types shown in the diagrams can be
set through the respective fixed-point properties of the object.

**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 specify `OptimizeUnityScaleValues`

to
`true`

, and scale values to 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 you specify
`OptimizeUnityScaleValues`

to `true`

, and
scale values to 1.

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

When the data is not optimized:

When you specify `OptimizeUnityScaleValues`

to
`true`

, and scale values to 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 you specify
`OptimizeUnityScaleValues`

to `true`

, and
scale values to 1.

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

When the data is not optimized:

When you specify `OptimizeUnityScaleValues`

to
`true`

, and scale values to 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 specify `OptimizeUnityScaleValues`

to
`true`

, and scale values to 1:

## Algorithms

This object implements the algorithm, inputs, and outputs described on the Biquad Filter block reference page. The object properties correspond to the block parameters, except:

**Coefficient source****Action when the a0 values of the SOS matrix are not one**– the biquad filter object assumes the zero-th-order denominator coefficient equals 1 regardless of the specified value. The biquad filter object does not support the`Error`

or`Warn`

options found in the corresponding block.

Both this object and its corresponding block support variable-size input. When you call the object, it can handle an input argument which is changing in size.

## Extended Capabilities

### C/C++ Code Generation

Generate C and C++ code using MATLAB® Coder™.

Usage notes and limitations:

See System Objects in MATLAB Code Generation (MATLAB Coder).

### HDL Code Generation

Generate Verilog and VHDL code for FPGA and ASIC designs using HDL Coder™.

This object supports HDL code generation with the HDL Coder™ or Filter Design HDL Coder™ products. For HDL Coder workflows and limitations, see HDL Code Generation for System Objects (HDL Coder). For Filter Design HDL Coder workflows and limitations, see Generate HDL Code for Filter System Objects (Filter Design HDL Coder).

## Version History

**Introduced in R2012a**

## Open Example

You have a modified version of this example. Do you want to open this example with your edits?

## MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

# Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)