Package: dsp
Infinite Impulse Response (IIR) filter
The IIRFilter
object filters each channel
of the input using IIR filter implementations.
To filter each channel of the input:
Define and set up your IIR filter. See Construction.
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.
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('
returns an IIR filter System object, PropertyName
',PropertyValue
,
...)HIIR
,
with each property set to the specified value.

Filter structure Specify the filter structure.
 

Filter numerator coefficients Specify the numerator coefficients as a real or complex numeric
row vector. The default is  

Filter denominator coefficients Specify the denominator coefficients as a real or complex numeric
row vector. The default value of this property is  

Initial conditions for the IIR filter Specify the initial conditions of the filter states. This property
is applicable when the structure is one of 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.  

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 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.  

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 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.  

Numerator coefficients word and fractionlength designations Specify the numerator coefficients fixedpoint data type as
one of  

Denominator coefficients word and fractionlength designations Specify the denominator coefficients fixedpoint data type as
one of 
clone  Create IIR filter 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 internal states of IIR filter 
step  Filter input with IIR filter object 
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 = xmean(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)
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
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);
This object implements the algorithm, inputs, and outputs described on the Discrete Filter block reference page. The object properties correspond to the block parameters.