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)
Zf = idfilt(___,Name,Value)
Description
Zf = idfilt(Z,filter)
filters data using user-defined passbands, general
filters, or Butterworth filters.
Z
contains time-domain or frequency-domain input/output data.
Z
can be in the form of a timetable
, a comma-separated pair of numeric matrices, or an iddata
object.
Zf
contains the filtered data in the same form as
Z
.
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 is5
.For time-domain data — The passbands are in units of
rad/TimeUnit
, whereTimeUnit
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
andws2
, 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 frequencyZ.Frequency(kf)
are multiplied byWf(kf)
.Wf
is a column vector of length = number of frequencies inZ
. If the data object has several experiments,Wf
is a cell array of length = # of experiments inZ
.
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
.
Zf = idfilt(___,
uses
additional model options specified by one or more name-value arguments. Name,Value)
The available arguments consist of:
InputName
andOutputName
— Input and output channel names. Use these arguments especially whendata
is a timetable that has more variables than you want to use, or when there. Also useOutputName
to identify the output channels when the timetabledata
contains more than one output variable. Otherwise, the software interprets only the last variable as an output channel.For example, specify the input and output signal variable names using
sys = idfilt(data,'InputName',["u1","u3"],'OutputName',"y1")
. You can use this syntax with any of the previous input-argument combinations.Ts
andTimeUnit
— Sample time and time units. Use these arguments especially when you aredata
contains numeric matrices, which do not provide sample-time information.
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.