IIRFilter (FPScript)

21.09.2021

Calculates the numerator and denominator coefficients or the poles and zeros of an infinite impulse response filter (IIR filter).

Syntax

IIRFilter(Filter, Type, [ Order ], CutOffFrequencies, [ PassBand = 3 ], [ StopBand = 40 ], [ Mode = FILTER_DB ], [ Result = FILTER_COEFFICIENTS ] [ , SamplingRate ])

 

The syntax of the IIRFilter function consists of the following parts:

Part

Description

Filter

Specifies the filter characteristics.

The argument Filter can have the following values:

Constant

Meaning

FILTER_BESSEL

Filter with a flat passband and relatively low steepness.

FILTER_BUTTERWORTH

Filter with a flat passband and higher steepness, but with overshoots in the case of signals with steep slopes.

FILTER_CHEBYSHEV

Filter with high steepness. The ripple for the passband can be adjusted under PassBand.

FILTER_INVERSECHEBYSHEV O

Filter with high steepness. The ripple for the stop band can be adjusted under StopBand.

O This constant requires the option Digital Filters to be licensed.

FILTER_ELLIPTIC O

Also known as the Cauer filter. Both the passband ripple and the stop band attenuation can be adjusted.

O This constant requires the option Digital Filters to be licensed.

FILTER_LEGENDRE O

Also known as the Optimum "L" filter. It is steeper than the Butterworth filter but in contrast to the Chebyshev filter is monontonic in the passband.

O This constant requires the option Digital Filters to be licensed.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

Type

Specifies the filter type.

The argument Type can have the following values:

Constant

Meaning

FILTER_LOWPASS

Low pass, allows frequencies to pass that are below the cut-off frequency.

FILTER_HIGHPASS

High pass, allows frequencies to pass that are above the cut-off frequency.

FILTER_BANDPASS

Bandpass, allows frequencies to pass that are between the first and second cut-off frequency.

FILTER_BANDSTOP

Bandstop, allows frequencies to pass that are below the first and above the second cut-off frequency.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

Order

Specifies the filter order. Orders 1 through 20 are allowed. The argument is optional if, instead of the cut-off frequency, the passband edge and the stop band edge are specified for the transitions from the passband to the stop band and vice versa. In this case, the optimal filter order is estimated. The order must be specified for the Bessel filter.

Permitted data structures are scalar value. All integral data types are permitted.

The value must be greater or equal to 1 and less or equal to 20.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

CutOffFrequencies

Specifies the filter's cut-off frequencies or transitions. The frequencies must be between 0 and half of the sampling frequency or between 0 and 0.5, half of the normalized sampling frequency. If the order is specified, a scalar value must be specified for the low pass or high pass filter, and a data series with two values must be provided for the bandpass and bandstop filters. To estimate the filter order, the transitions must be specified as a data matrix with 2 values each.

Permitted data structures are scalar value, data series und data matrix. All real data types are permitted, except calendar time und time span.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

PassBand

Specifies the ripple of the Chebyshev or Elliptic filter in the passband in decibels or the error in the passband.

Permitted data structures are scalar value. All real data types are permitted, except calendar time und time span.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

If this argument is omitted, it will be set to the default value 3.

StopBand

Specifies the attenuation of the Inverse Chebyshev or Elliptic filter in the stop band in decibels or the error in the stop band.

Permitted data structures are scalar value. All real data types are permitted, except calendar time und time span.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

If this argument is omitted, it will be set to the default value 40.

Mode

Specifies whether the attenuation / ripple in decibels, or the error is specified.

The argument Mode can have the following values:

Constant

Meaning

FILTER_DELTA

The error is specified for the passband or the stop band.

FILTER_DB

The filter's ripple is specified for the passband, and the attenuation is specified in decibels for the stop band.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

If this argument is omitted, it will be set to the default value FILTER_DB.

Result

Specifies whether the filter coefficients or poles and zeros are returned as the result.

The argument Result can have the following values:

Constant

Meaning

FILTER_COEFFICIENTS

The filter coefficients are returned as the result.

FILTER_POLESANDZEROS O

Poles and zeros are returned as the result.

O This constant requires the option Digital Filters to be licensed.

FILTER_COEFFICIENTSCASCADED

The filter coefficients of the second order cascaded IIR Filter are returned as the result.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

If this argument is omitted, it will be set to the default value FILTER_COEFFICIENTS.

SamplingRate

Specifies the sampling rate of the signal to be filtered. If this argument is omitted, the normalized frequencies from 0 to 0.5 must be specified as the cut-off frequencies.

Permitted data structures are scalar value. All real data types are permitted, except calendar time und time span.

The value must be greater than 0.

If the argument is a list, then the function is executed for each element of the list and the result is also a list.

Remarks

The numerator and denominator coefficients are returned as a list with two elements a and b. These can be presented as a data series or as three-row data matrices for the coefficients of a cascade of 2nd order filters. Use the Filterfunction to filter data with the calculated filter.

The ripple for the passband can be specified in decibels for the Chebyshev and Elliptic filters. The stop band attenuation can be specified in decibels for the Inverse Chebyshev and Elliptic filters. Alternatively, the relative error can be specified for the passband or stop band. All values are specified as absolute values.

The following applies: Ripple = | 20 log( 1 / (1 - relative passband error)) |

Attenuation = | 20 log( relative stop band error ) |

A relative stop band error of 0.1 is equivalent to an attenuation of 20 decibels.

Note        An increase in order causes the filter steepness to be higher.

Available in

FlexPro Basic, Professional, Developer Suite

Examples

IIRFilter(FILTER_BUTTERWORTH, FILTER_LOWPASS, 5, 0.2)

Calculates the coefficients of a Butterworth low pass filter of the 5th order with the normalized cut-off frequency of 0.2.

Filter(Signal, IIRFilter(FILTER_BUTTERWORTH, FILTER_LOWPASS, 5, 0.5 kHz, , , , , SamplingRate(Signal)), TRUE)

Filters a signal with phase correction using a low-pass filter with a 500 Hz cut-off frequency.

IIRFilter(FILTER_ELLIPTIC, FILTER_BANDSTOP, 5, {0.1, 0.2}, 2 dB, 45 dB)

Calculates the bandstop coefficients of a Cauer filter with 2 dB ripple and 45 dB attenuation.

IIRFilter(FILTER_CHEBYSHEV, FILTER_HIGHPASS,, {{0.1, 0.15}}, 0.01, 0.01, FILTER_DELTA)

Estimates the filter order and calculates the coefficients of a Chebyshev high pass filter with the error of 0.01 in the stop band and passband with the stop band edge of 0.1 and the passband edge of 0.15.

See Also

Filter Function

FIRFilterEquiripple Function

FIRFilterWindow Function

DCRemovalFilter Function

Digital Filters Option

IIR Filter Analysis Object

Filter Tutorial

Share article or send as email:

You might be interested in these articles