Documentation

This is machine translation

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

dsp.IIRFilter System object

Package: dsp

Infinite Impulse Response (IIR) filter

Description

The IIRFilter object filters each channel of the input using IIR filter implementations.

To filter each channel of the input:

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

  2. Call step to filter each channel of the input according to the properties of dsp.IIRFilter. 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

HIIR = dsp.IIRFilter returns an IIR filter System object, HIIR, which independently filters each channel of the input over successive calls to the step method. This System object uses a specified IIR filter implementation.

HIIR = dsp.IIRFilter('PropertyName',PropertyValue, ...) returns an IIR filter System object, HIIR, with each property set to the specified value.

Properties

Structure

Filter structure

Specify the filter structure.

You can 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. This property is nontunable.

Numerator

Filter numerator coefficients

Specify the numerator coefficients as a real or complex numeric row vector. The default is [1 1]. This property is tunable.

Denominator

Filter denominator coefficients

Specify the denominator coefficients as a real or complex numeric row vector. The default value of this property is [1 0.1]. This property is tunable.

InitialConditions

Initial conditions for the IIR filter

Specify the initial conditions of the filter states. This property is applicable when the structure is one of Direct form II | Direct form II transposed. The default value is 0. The number of states equals the max(N,M)-1, where N and M are the number of poles and zeros respectively.

You can specify the initial conditions as a scalar, vector, or matrix. If you specify a scalar value, this System object initializes all delay elements in the filter to that value. You can also specify a vector whose length equals the number of delay elements in the filter. When you do so, each vector element specifies a unique initial condition for the corresponding delay element. The object applies the same vector of initial conditions to each channel of the input signal.

You can also 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. In this case, each element specifies a unique initial condition for the corresponding delay element in the corresponding channel. This property is tunable.

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 is applicable when the Structure property is one of Direct form I | Direct form I transposed. The default value of this property is 0. The number of states equals the max(N,M)-1, where N and M are the number of poles and zeros respectively.

You can specify the initial conditions as a scalar, vector, or matrix. When you specify a scalar, the IIR filter initializes all delay elements on the zeros side in the filter to that value. You can specify a vector of length equal to the number of delay elements on the zeros side in the filter. When you do so, each vector element specifies a unique initial condition for the corresponding delay element on the zeros side.

You can also 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. In this case, each element specifies a unique initial condition for the corresponding delay element on the zeros side in the corresponding channel. This property is tunable.

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 is applicable when the Structure property is one of Direct form I | Direct form I transposed. The default value of this property is 0. The number of states equals the max(N,M)-1, where N and M are the number of poles and zeros respectively.

You can specify the initial conditions as a scalar, vector, or matrix. When you specify a scalar, the IIR filter initializes all delay elements on the poles side of the filter to that value. You can specify a vector of length equal to the number of delay elements on the poles side in the filter. When you do so, each vector element specifies a unique initial condition for the corresponding delay element on the poles side.

You can also 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. In this case, each element specifies a unique initial condition for the corresponding delay element on the poles side in the corresponding channel. This property is tunable.

NumeratorCoefficientsDataType

Numerator coefficients word- and fraction-length designations

Specify the numerator coefficients fixed-point data type as one of Same word length as input | Custom. The default is Same word length as input. This property is nontunable.

DenominatorCoefficientsDataType

Denominator coefficients word- and fraction-length designations

Specify the denominator coefficients fixed-point data type as one of Same word length as input | Custom. The default is Same word length as input. This property is nontunable.

 Fixed-Point Properties

Methods

cloneCreate IIR filter with same property values
freqzFrequency response
fvtoolOpen filter visualization tool
getNumInputsNumber of expected inputs to step method
getNumOutputsNumber of outputs of step method
impzImpulse response
isLockedLocked status for input attributes and nontunable properties
phasezUnwrapped phase response
releaseAllow property value and input characteristics changes
resetReset internal states of IIR filter
stepFilter input with IIR filter object

More Analysis Methods for Filter System Objects.

Examples

expand all

This example shows how to filter a noisy signal with a dsp.IIRFilter System object™. View the magnitude response of the IIR filter. Use the Spectrum Analyzer to display the power spectrum of the output signal.

Initialization

x = randn(2048,1);
x = x-mean(x);
Hsr = dsp.SignalSource;
Hsr.Signal = x;
Hlog = dsp.SignalSink;

N = 10;
Fc = 0.4;
[b,a] = butter(N,Fc);
H = dsp.IIRFilter('Numerator',b,'Denominator',a);

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

Filter the Signal

while ~isDone(Hsr)
  input = Hsr();
  output = H(input);
  h(output)
  Hlog(output);
end

Result = Hlog.Buffer;
fvtool(H,'Fs',8000)

This example shows the two ways of designing an IIR Filter

Design the filter using fdesign and design.

D = fdesign.comb('notch','N,BW',8,0.02);
H = design(D,'systemobject',true)
fvtool(H);
H = 

  dsp.IIRFilter with properties:

            Structure: 'Direct form II'
            Numerator: [0.8878 0 0 0 0 0 0 0 -0.8878]
          Denominator: [1 0 0 0 0 0 0 0 -0.7757]
    InitialConditions: 0

  Use get to show all properties

Design the filter using filter coefficients.

b = [0.9 zeros(9,1)' -0.9];
a = [1 zeros(9,1)' -0.8];
H = dsp.IIRFilter('Numerator',b,'Denominator',a)
fvtool(H);
H = 

  dsp.IIRFilter with properties:

            Structure: 'Direct form II transposed'
            Numerator: [0.9000 0 0 0 0 0 0 0 0 0 -0.9000]
          Denominator: [1 0 0 0 0 0 0 0 0 0 -0.8000]
    InitialConditions: 0

  Use get to show all properties

Algorithms

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

Introduced in R2012b

Was this topic helpful?