# Documentation

### This is machine translation

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

# dsp.BiquadFilter System object

Package: dsp

IIR filter using biquadratic structures

## Description

The BiquadFilter object implements an IIR filter structure using biquadratic or second–order sections (SOS).

To implement an IIR filter structure using biquadratic or SOS:

1. Define and set up your biquadratic IIR filter. See Construction.

2. Call step to implement the IIR filter according to the properties of dsp.BiquadFilter. The behavior of step is specific to each object in the toolbox.

 Note:   Starting in R2016b, instead of using the step method to perform the operation defined by the System object™, you can call the object with arguments, as if it were a function. For example, y = step(obj,x) and y = obj(x) perform equivalent operations.

## Construction

H = dsp.BiquadFilter returns a default biquadratic IIR filter, H, which independently filters each channel of the input over successive calls to the step method using the SOS section[1 0.3 0.4 1 0.1 0.2] with a direct-form II transposed structure.

H = dsp.BiquadFilter('PropertyName',PropertyValue, ...) returns a biquadratic filter object, H, with each property set to the specified value.

## Properties

 Structure Filter structure Specify the filter structure as one of | Direct form I | Direct form I transposed | Direct form II | Direct form II transposed |. The default is Direct form II transposed. SOSMatrixSource SOS matrix source Specify the source of the SOS matrix as one of | Property | Input port|. The default is Property. SOSMatrix SOS matrix Specify the second-order section (SOS) matrix as an N-by-6 matrix, where N is the number of sections in the filter. The default is [1 0.3 0.4 1 0.1 0.2]. 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\left(z\right)=\frac{\sum _{k=0}^{2}{b}_{k}{z}^{-k}}{1-\sum _{l=1}^{2}{a}_{l}{z}^{-l}}$The coefficients are ordered in the rows of the SOS matrix as (b0, b1,b2,1, –a1, –a2). 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, a0, equals 1 for each filter section, regardless of the specified value. ScaleValues Scale values for each biquad section 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+1values, each value is used for a separate section of the filter. This property applies only when you set the SOSMatrixSource property to Property. The default is 1. InitialConditions Initial conditions for direct form II structures 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. The default is the scalar 0. NumeratorInitialConditions Initial conditions on zeros side Specify the initial conditions of the filter states on the side of the filter structure with the zeros. This property applies only when you set the Structure property to one of | Direct form I | Direct form I transposed |. 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. The default is the scalar 0. DenominatorInitialConditions Initial conditions on poles side Specify the initial conditions of the filter states on the side of the filter structure with the poles. This property only applies when you set the Structure property to one of | Direct form I | Direct form I transposed |. 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. The default is the scalar 0. OptimizeUnityScaleValues Optimize unity scale values 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. This property applies only when you set the SOSMatrixSource property to Property. The default is true. ScaleValuesInputPort How to specify scale values Select how to specify scale values. This property applies only when the SOSMatrixSource property is Input port. 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.

## Methods

 clone Create biquad filter object with same property values freqz Frequency response fvtool Open filter visualization tool getNumInputs Number of expected inputs to step method getNumOutputs Number of outputs of step method impz Impulse response isLocked Locked status for input attributes and nontunable properties phasez Unwrapped phase response release Allow property value and input characteristics changes reset Reset states of biquad filter object step Filter input with biquad filter object

## Examples

expand all

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 &amp;
% 3kHz sinusoids
hFromWS = dsp.SignalSource(xin, 100);
hLog = dsp.SignalSink;

[z,p,k] = ellip(4,1,60,.4);    % Set up the filter
[s,g] = zp2sos(z,p,k);
hBqF=dsp.BiquadFilter('Structure','Direct form I', ...
'SOSMatrix',s,'ScaleValues',g);

h = dsp.SpectrumAnalyzer('SampleRate',8e3,...
'PlotAsTwoSidedSpectrum',false,...
'OverlapPercent', 80,'PowerUnits','dBW',...
'YLimits', [-160 -10]);

while ~isDone(hFromWS)
input = hFromWS();
filteredOutput = hBqF(input);
hLog(filteredOutput);
h(filteredOutput)
end

filteredResult = hLog.Buffer;
fvtool(hBqF,'Fs',8000)

Design and apply a lowpass biquad filter System object™ using the design function.

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

Structure: 'Direct form II'
SOSMatrixSource: 'Property'
SOSMatrix: [42×6 double]
ScaleValues: [43×1 double]
InitialConditions: 0
OptimizeUnityScaleValues: true

Use get to show all properties

## Algorithm

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 – the biquad filter object does not accept dfilt objects as an SOSMatrixSource.

• 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. This means that the step method can handle an input which is changing in size.