Documentation Center

  • Trial Software
  • Product Updates

Contents

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.

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.

FrameBasedProcessing

Process input as frames or as samples

Set this property to true to enable frame-based processing. When this property is true, the IIR filter treats each column as an independent channel. Set this property to false to enable sample-based processing. When this property is false, the IIR filter treats each element of the input as an individual channel. The default is true. This property is nontunable.

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

  1. Use fvtool to see the magnitude response of a lowpass IIR filter. Also use the Spectrum Analyzer to display the power spectrum of the output signal.

    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]);
    
    while ~isDone(Hsr)
      input = step(Hsr);
      output = step(H,input);
      step(h,output)
      step(Hlog,output);
    end
    
    Result = Hlog.Buffer;
    fvtool(H,'Fs',8000)
    
    

  2. Design an IIR filter as a System object.

    The are two ways, either you first design the constructor and then design the filter as a System object that you can apply:

    D = fdesign.comb('notch','N,BW',8,0.02);
    H = design(D,'systemobject',true)
    fvtool(H);
    
    H = 
    
      System: dsp.IIRFilter 
    
      Properties:
                   Structure: 'Direct form II'                                    
                   Numerator: [0.887839755524806 0 0 0 0 0 0 0 -0.887839755524806]
                 Denominator: [1 0 0 0 0 0 0 0 -0.775679511049613]                
           InitialConditions: 0                                                   
        FrameBasedProcessing: true              

    or, you have the filter coefficients, and then you use dsp.IIRFilter, to apply it:

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

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.

Both this object and its corresponding block let you specify whether to process inputs as individual samples or as frames of data. The object uses the FrameBasedProcessing property. The block uses the Input processing parameter. See Set the FrameBasedProcessing Property of a System object for more information.

See Also

| |

Was this topic helpful?