Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

**MathWorks Machine Translation**

The automated translation of this page is provided by a general purpose third party translator tool.

MathWorks does not warrant, and disclaims all liability for, the accuracy, suitability, or fitness for purpose of the translation.

Infinite impulse response (IIR) filter

The `dsp.IIRFilter`

System
object™ filters each channel of the input using the specified filter. You can specify
the filter to have a `'Direct form I'`

, ```
'Direct form I
transposed'
```

, `'Direct form II'`

, or ```
'Direct form II
transposed'
```

structure.

Use the Numerator and Denominator properties to specify the coefficients of the filter numerator and denominator coefficients. In addition to these coefficients, you can also specify nonzero initial filter states through the InitialConditions property.

To filter a signal using an IIR filter:

Create the

`dsp.IIRFilter`

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? (MATLAB).

`iir = dsp.IIRFilter`

`iir = dsp.IIRFilter(Name,Value)`

creates an infinite
impulse response (IIR) filter System
object that independently filters each channel of the input over time using a
specified IIR filter implementation.`iir`

= dsp.IIRFilter

creates an IIR filter object with each specified property set to the specified value.
Enclose each property name in single quotes.`iir`

= dsp.IIRFilter(`Name,Value`

)

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 (MATLAB).

`Structure`

— IIR filter structure`'Direct form II transposed'`

(default) | `'Direct form I'`

| `'Direct form I transposed'`

| `'Direct form II'`

IIR filter structure, specified as `'Direct form I'`

,
`'Direct form I transposed'`

, `'Direct form II'`

, or
`'Direct form II transposed'`

.

`Numerator`

— Numerator coefficients`[1 1]`

(default) | row vectorNumerator coefficients, specified as a row vector.

**Example: **[```
0.0296 0.1775 0.4438 0.5918 0.4438 0.1775
0.0296
```

]

**Tunable: **Yes

**Data Types: **`single`

| `double`

| `int8`

| `int16`

| `int32`

| `int64`

| `uint8`

| `uint16`

| `uint32`

| `uint64`

**Complex Number Support: **Yes

`Denominator`

— Denominator coefficients`[1 0.1]`

(default) | row vectorDenominator coefficients, specified as a row vector.

**Example: **[```
1.0000 -0.0000 0.7777 -0.0000 0.1142 -0.0000
0.0018
```

]

**Tunable: **Yes

**Data Types: **`single`

| `double`

| `int8`

| `int16`

| `int32`

| `int64`

| `uint8`

| `uint16`

| `uint32`

| `uint64`

**Complex Number Support: **Yes

`InitialConditions`

— Initial conditions`0`

(default) | scalar | vector | matrixInitial conditions of the filter states, specified as one of the following:

scalar –– The object initializes all delay elements in the filter to the scalar value.

vector –– The length of the vector equals the number of delay elements in the filter. Each vector element specifies a unique initial condition for the corresponding delay element. The object applies the same vector to each channel of the input signal.

matrix –– The number of rows in the matrix must equal the number of delay elements in the filter. The number of columns in the matrix must equal the number of channels in the input. Each element specifies a unique initial condition for the corresponding delay element in the corresponding channel.

The number of filter states equals
max(*N*,*M*) – 1, where *N* is the
number of poles, and *M* is the number of zeros.

**Tunable: **Yes

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

or `'Direct form II transposed'`

.

**Data Types: **`single`

| `double`

| `int8`

| `int16`

| `int32`

| `int64`

| `uint8`

| `uint16`

| `uint32`

| `uint64`

**Complex Number Support: **Yes

`NumeratorInitialConditions`

— Initial conditions on zeros side`0`

(default) | scalar | vector | matrixInitial conditions of the filter states on the side of the filter structure with the zeros, specified as one of the following:

scalar –– The object initializes all delay elements on the zeros side in the filter to the scalar value.

vector –– The length of the vector equals 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 object applies the same vector of initial conditions to each channel of the input signal.

matrix –– The number of rows in the matrix must equal the number of delay elements on the zeros side in the filter. The number of columns in the matrix must equal the number of channels in the input signal. Each element specifies a unique initial condition for the corresponding delay element on the zeros side in the corresponding channel.

The number of filter states equals
max(*N*,*M*) – 1, where *N* is the
number of poles, and *M* is the number of zeros, respectively.

**Tunable: **Yes

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

or `'Direct form I transposed'`

.

**Data Types: **`single`

| `double`

| `int8`

| `int16`

| `int32`

| `int64`

| `uint8`

| `uint16`

| `uint32`

| `uint64`

**Complex Number Support: **Yes

`DenominatorInitialConditions`

— Initial conditions on poles side`0`

(default) | scalar | vector | matrixInitial conditions of the filter states on the side of the filter structure with the poles, specified as one of the following:

scalar –– The object initializes all delay elements on the poles side in the filter to the scalar value.

vector –– The length of the vector equals 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.

matrix –– The number of rows in the matrix must equal the number of delay elements on the poles side in the filter. The number of columns in the matrix must equal the number of channels in the input signal. Each element specifies a unique initial condition for the corresponding delay element on the poles side in the corresponding channel.

The number of filter states equals
max(*N*,*M*) – 1, where *N* is the
number of poles, and *M* is the number of zeros, respectively.

**Tunable: **Yes

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

or `'Direct form I transposed'`

.

**Data Types: **`single`

| `double`

| `int8`

| `int16`

| `int32`

| `int64`

| `uint8`

| `uint16`

| `uint32`

| `uint64`

**Complex Number Support: **Yes

`RoundingMethod`

— Rounding method`'Floor'`

(default) | `'Ceiling'`

| `'Convergent'`

| `'Nearest'`

| `'Round'`

| `'Simplest'`

| `'Zero'`

Select the rounding mode for fixed-point operations.

`OverflowAction`

— Overflow action`'Wrap'`

(default) | `'Saturate'`

Overflow action for fixed-point operations, specified as one of the following:

`'Wrap'`

–– The object wraps the result of its fixed-point operations.`'Saturate'`

–– The object saturates the result of its fixed-point operations.

For more details on overflow actions, see overflow mode for fixed-point operations.

`StateDataType`

— State data type`'Same as input'`

(default) | `'Custom'`

State data type, specified as one of the following:

`'Same as input'`

–– The state data type is same as the input data type.`'Custom'`

–– The state output data type is an autosigned numeric type through the CustomStateDataType property.

`CustomStateDataType`

— State word and fraction lengths`numerictype([],16,15)`

(default)State word and fraction lengths, specified as an autosigned numeric type with a word length of 16 and a fraction length of 15.

This property applies only when you set StateDataType to
`'Custom'`

.

`NumeratorCoefficientsDataType`

— Data type of numerator coefficients`'Same word length as input'`

(default) | `'Custom'`

Data type of numerator coefficients, specified as one of the following:

`'Same word length as input'`

–– The word length of the numerator coefficients is the same as the input word length. The fraction length is chosen to give the best possible precision.`'Custom'`

–– The data type of the numerator coefficients is the autosigned numeric type specified by the CustomNumeratorCoefficientsDataType property.

`CustomNumeratorCoefficientsDataType`

— Word and fraction lengths of the numerator coefficients`numerictype([],16,15)`

(default)Word and fraction lengths of the numerator coefficients, specified as an autosigned numeric type with a word length of 16 and a fraction length of 15.

This property applies only when you set NumeratorCoefficientsDataType to
`'Custom'`

.

`DenominatorCoefficientsDataType`

— Data type of the denominator coefficients`'Same word length as input'`

(default) | `'Custom'`

Data type of the denominator coefficients, specified as one of the following:

`'Same word length as input'`

–– The word length of the denominator coefficients is the same as that of the input word length. The fraction length is chosen to give the best possible precision.`'Custom'`

–– The data type of the denominator coefficients is the autosigned numeric type specified by the CustomDenominatorCoefficientsDataType property.

`CustomDenominatorCoefficientsDataType`

— Word and fraction lengths of denominator coefficients`numerictype([],16,15)`

(default)Word and fraction lengths of denominator coefficients, specified as an autosigned numeric type with a word length of 16 and a fraction length of 15.

This property applies only when you set DenominatorCoefficientsDataType to
`'Custom'`

.

`NumeratorProductDataType`

— Numerator product data type`'Full precision'`

(default) | `'Same as input'`

| `'Custom'`

Data type of the output of a product operation in the numerator polynomial of the IIR filter, specified as one of the following:

`'Full precision'`

–– The object computes the numerator product output data type using the full-precision rules. These rules provide the most accurate fixed-point numerics. No quantization occurs. Bits are added, as needed, to ensure that no roundoff or overflow occurs.`'Same as input'`

–– The product output data type is the same as the input data type.`'Custom'`

–– The product output data type is the custom numeric type specified by the CustomNumeratorProductDataType property. The rounding method and the overflow action are specified by the RoundingMethod and OverflowAction properties.

`CustomNumeratorProductDataType`

— Numerator product word and fraction lengths`numerictype([],32,30)`

(default)Numerator product word and fraction lengths, specified as an autosigned numeric type with a word length of 32 and a fraction length of 30.

This property applies only when you set NumeratorProductDataType to
`'Custom'`

.

`DenominatorProductDataType`

— Denominator product data type`'Full precision'`

(default) | `'Same as input'`

| `'Custom'`

Data type of the output of a product operation in the denominator polynomial of the IIR filter, specified as one of the following:

`'Full precision'`

–– The object computes the denominator product output data type using the full-precision rules. These rules provide the most accurate fixed-point numerics. No quantization occurs. Bits are added, as needed, to ensure that no roundoff or overflow occurs.`'Same as input'`

–– The product output data type is the same as the input data type.`'Custom'`

–– The product output data type is custom numeric type specified by the CustomDenominatorProductDataType property. The rounding method and the overflow action are specified by the RoundingMethod and OverflowAction properties.

`CustomDenominatorProductDataType`

— Denominator product word and fraction lengths`numerictype([],32,30)`

(default)Denominator product word and fraction lengths, specified as an autosigned numeric type with a word length of 32 and a fraction length of 30.

This property applies only when you set DenominatorProductDataType to
`'Custom'`

.

`NumeratorAccumulatorDataType`

— Numerator accumulator data type`'Full precision'`

(default) | `'Same as input'`

| `'Same as product'`

| `'Custom'`

Data type of the output of an accumulation operation in the numerator polynomial of the IIR filter, specified as one of the following:

`'Full precision'`

–– The object computes the numerator accumulator data type using the full-precision rules. These rules provide the most accurate fixed-point numerics. No quantization occurs. Bits are added, as needed, to ensure that no roundoff or overflow occurs.`'Same as input'`

–– The accumulator data type is the same as the input data type.`'Same as product'`

–– The accumulator data type is the same as the product output data type.`'Custom'`

–– The accumulator data type is the custom numeric type specified by the CustomNumeratorAccumulatorDataType property. The rounding method and the overflow action are specified by the RoundingMethod and OverflowAction properties.

`CustomNumeratorAccumulatorDataType`

— Numerator accumulator word and fraction lengths`numerictype([],32,30)`

(default)Numerator accumulator word and fraction lengths, specified as an autosigned numeric type with a word length of 32 and a fraction length of 30.

This property applies only when you set NumeratorAccumulatorDataType to
`'Custom'`

.

`DenominatorAccumulatorDataType`

— Denominator accumulator data type`'Full precision'`

(default) | `'Same as input'`

| `'Same as product'`

| `'Custom'`

Data type of the output of an accumulation operation in the denominator polynomial of the IIR filter, specified as one of the following:

`'Full precision'`

–– The object computes the denominator accumulator data type using the full-precision rules. These rules provide the most accurate fixed-point numerics. No quantization occurs. Bits are added, as needed, to ensure that no roundoff or overflow occurs.`'Same as input'`

–– The accumulator data type is the same as the input data type.`'Same as product'`

–– The accumulator data type is the same as the product output data type.`'Custom'`

–– The accumulator data type is the custom numeric type specified by the CustomDenominatorAccumulatorDataType property. The rounding method and the overflow action are specified by the RoundingMethod and OverflowAction properties.

`CustomDenominatorAccumulatorDataType`

— Denominator accumulator word and fraction lengths`numerictype([],32,30)`

(default)Denominator accumulator word and fraction lengths, specified as an autosigned numeric type with a word length of 32 and a fraction length of 30.

This property applies only when you set DenominatorAccumulatorDataType to
`'Custom'`

.

`OutputDataType`

— Output data type`'Same as input'`

(default) | `'Full precision'`

| `'Custom'`

Data type of the output of the `dsp.IIRFilter`

object, specified as
one of the following:

`'Same as input'`

–– The output data type is the same as the input data type.`'Full precision'`

–– The object computes the output data type using the full-precision rules. These rules provide the most accurate fixed-point numerics. No quantization occurs. Bits are added, as needed, to ensure that no roundoff or overflow occurs.`'Custom'`

–– The output data type is the custom numeric type specified by the CustomOutputDataType property. The rounding method and the overflow action are specified by the RoundingMethod and OverflowAction properties.

`CustomOutputDataType`

— Output word and fraction lengths`numerictype([],16,15)`

(default)Output word and fraction lengths, specified as an autosigned numeric type with a word length of 16 and a fraction length of 15.

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

.

`MultiplicandDataType`

— Multiplicand data type`'Same as input'`

(default) | `'Custom'`

Multiplicand data type, specified as one of the following:

`'Same as input'`

–– The multiplicand data type is the same as the input data type.`'Custom'`

–– The multiplicand data type is the autosigned numeric type specifies by the CustomMultiplicandDataType property.

`CustomMultiplicandDataType`

— Multiplicand output word and fraction lengths`numerictype([],16,15)`

(default)Multiplicand output word and fraction lengths, specified as an autosigned numeric type with a word length of 16 and a fraction length of 15.

This property applies only when you set MultiplicandDataType to
`'Custom'`

.

**For versions earlier than R2016b, use the step
function to run the System object algorithm. The arguments to
step are the object you created, followed by
the arguments shown in this section.**

**For example, y = step(obj,x) and y = obj(x) perform equivalent operations.**

`iirOut = iir(input)`

`input`

— Data inputvector | matrix

Data input that is filtered, specified as a vector or matrix.

**Example: **`randn(34,24)`

**Data Types: **`single`

| `double`

| `int8`

| `int16`

| `int32`

| `int64`

| `fi`

**Complex Number Support: **Yes

`iirOut`

— Filtered outputvector | matrix

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

**Data Types: **`single`

| `double`

| `int8`

| `int16`

| `int32`

| `int64`

| `fi`

**Complex Number Support: **Yes

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

For a list of filter analysis methods this object supports, type
`dsp.IIRFilter.helpFilterAnalysis`

in the MATLAB^{®} command prompt. For the corresponding function reference pages, see Analysis Methods for Filter System Objects.

**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)`

.

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); src = dsp.SignalSource; src.Signal = x; sink = dsp.SignalSink; N = 10; Fc = 0.4; [b,a] = butter(N,Fc); iir = dsp.IIRFilter('Numerator',b,'Denominator',a); sa = dsp.SpectrumAnalyzer('SampleRate',8e3,... 'PlotAsTwoSidedSpectrum',false,... 'OverlapPercent',80,'PowerUnits','dBW',... 'YLimits',[-220 -10]);

**Filter the Signal**

while ~isDone(src) input = src(); output = iir(input); sa(output) sink(output); end Result = sink.Buffer; fvtool(iir,'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); iir = design(D,'systemobject',true)

iir = 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 Show all properties

fvtool(iir);

Design the filter using filter coefficients.

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

iir = 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 Show all properties

fvtool(iir);

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

Usage notes and limitations:

Only the

`Numerator`

and`Denominator`

properties are tunable for code generation.See System Objects in MATLAB Code Generation (MATLAB Coder).

Convert floating-point algorithms to fixed point using Fixed-Point Designer™.

The `dsp.IIRFilter`

System
object supports the following filter structures. The diagrams in each section show
the data types used in the filter structures for fixed-point signals. You can set the data
types using the fixed-point properties of the object.

The following constraints apply when the `Structure`

property is
set to `'Direct form I'`

:

Inputs can be real or complex.

Numerator and denominator coefficients can be real or complex.

Numerator and denominator coefficients must have the same complexity characteristics. When the numerator and denominator coefficients have different complexities from each other, the object processes the filter as if two sets of complex coefficients are provided. The real-valued coefficient set is treated as if it is a complex vector with zero-valued imaginary parts.

The State data type cannot be specified for this structure. Doing so is not possible because the input and output states have the same data types as the input and output buffers.

The following constraints apply when the `Structure`

property is
set to `'Direct form I transposed'`

:

Inputs can be real or complex.

Numerator and denominator coefficients can be real or complex.

Numerator and denominator coefficients must have the same complexity characteristics. When the numerator and denominator coefficients have different complexities from each other, the object processes the filter as if two sets of complex coefficients are provided. The real-valued coefficient set is treated as if it is a complex vector with zero-valued imaginary parts.

States are complex when either the input or the coefficients are complex.

The following constraints apply when the `Structure`

property is
set to `'Direct form II'`

:

Inputs can be real or complex.

Numerator and denominator coefficients can be real or complex.

Numerator and denominator coefficients must have the same complexity characteristics. When the numerator and denominator coefficients have different complexities from each other, the object processes the filter as if two sets of complex coefficients are provided. The real-valued coefficient set is treated as if it is a complex vector with zero-valued imaginary parts.

States are complex when either the inputs or the coefficients are complex.

The following constraints apply when the `Structure`

property is
set to `'Direct form II transposed'`

:

Inputs can be real or complex.

Numerator and denominator coefficients can be real or complex.

States are complex when either the inputs or the coefficients are complex.

아래 MATLAB 명령에 해당하는 링크를 클릭하셨습니다.

이 명령을 MATLAB 명령 창에 입력해 실행하십시오. 웹 브라우저에서는 MATLAB 명령을 지원하지 않습니다.

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

Select web siteYou can also select a web site from the following list:

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

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

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