# idfilt

Filter data using user-defined passbands, general filters, or Butterworth filters

## Syntax

`Zf = idfilt(Z,filter)`

Zf = idfilt(Z,filter,causality)

Zf = idfilt(Z,filter,'FilterOrder',NF)

## Description

`Zf = idfilt(Z,filter)`

filters data using
user-defined passbands, general filters, or Butterworth filters. `Z`

is
the data, defined as an `iddata`

object. `Zf`

contains
the filtered data as an `iddata`

object. The filter
can be defined in three ways:

As an explicit system that defines the filter.

filter = idm or filter = {num,den} or filter = {A,B,C,D}

`idm`

can be any SISO identified linear model or LTI model object. Alternatively the filter can be defined as a cell array`{A,B,C,D}`

of SISO state-space matrices or as a cell array`{num,den}`

of numerator/denominator filter coefficients.As a vector or matrix that defines one or several passbands.

filter=[[wp1l,wp1h];[ wp2l,wp2h]; ....;[wpnl,wpnh]]

The matrix is

`n`

-by-2, where each row defines a passband. A filter is constructed that gives the union of these passbands. For time-domain data, it is computed as cascaded Butterworth filters or order NF. The default value of NF is`5`

.For time-domain data — The passbands are in units of

`rad/TimeUnit`

, where`TimeUnit`

is the time units of the estimation data.For frequency-domain data — The passbands are in the frequency units (

`FrequencyUnit`

property) of the estimation data.

For example, to define a stopband between

`ws1`

and`ws2`

, usefilter = [0 ws1; ws2,Nyqf]

where

`Nyqf`

is the Nyquist frequency.For frequency-domain data, only the frequency response of the filter can be specified.

filter = Wf

Here

`Wf`

is a vector of possibly complex values that define the filter's frequency response, so that the inputs and outputs at frequency`Z.Frequency(kf)`

are multiplied by`Wf(kf)`

.`Wf`

is a column vector of length = number of frequencies in`Z`

. If the data object has several experiments,`Wf`

is a cell array of length = # of experiments in`Z`

.

`Zf = idfilt(Z,filter,causality)`

specifies
causality. For time-domain data, the filtering is carried out in the
time domain as causal filtering as default. This corresponds to a
last argument `causality = 'causal'`

. With ```
causality
= 'noncausal'
```

, a noncausal, zero-phase filter is used for
the filtering (corresponding to `filtfilt`

in the Signal Processing Toolbox™ product).

For frequency-domain data, the signals are multiplied by the
frequency response of the filter. With the filters defined as passband,
this gives ideal, zero-phase filtering (“brickwall filters”).
Frequencies that have been assigned zero weight by the filter (outside
the passband, or via the frequency response) are removed from the `iddata`

object `Zf`

.

`Zf = idfilt(Z,filter,'FilterOrder',NF)`

specifies
the filter order. The time domain filters in the pass-band case are
calculated as cascaded Butterworth pass-band and stop-band filters.
The orders of these filters are 5 by default, which can be changed
to an arbitrary integer `NF`

.

It is common practice in identification to select a frequency
band where the fit between model and data is concentrated. Often this
corresponds to bandpass filtering with a passband over the interesting
breakpoints in a Bode diagram. For identification where a disturbance
model is also estimated, it is better to achieve the desired estimation
result by using the `'WeightingFilter'`

option of
the estimation command than just to prefilter the data. The values
for `'WeightingFilter'`

are the same as the argument `filter`

in `idfilt`

.

## Algorithms

The Butterworth filter is the same as `butter`

in
the Signal Processing Toolbox product. Also, the zero-phase filter
is equivalent to `filtfilt`

in that toolbox.

## References

Ljung (1999), Chapter 14.

**Introduced before R2006a**