System Identification Toolbox | ![]() ![]() |
Package input-output data into the iddata
object.
Syntax
Description
iddata
is the basic object for dealing with signals in the toolbox. It is used by most of the commands.
Basic Use
Let y
be a column vector or an N-by-ny
matrix. The columns of y
correspond to the different output channels. Similarly, u
is a column vector or an N-by-nu matrix containing the signals of the input channels.
creates an iddata
object containing these output and input channels. Ts
is the sampling interval. This construction is sufficient for most purposes.
The data is then plotted by plot(data)
(see plot
), and portions of the data record are selected as in ze = data(1:300)
or zv = data(501:700)
.
The signals in the output channels are retrieved by data.OutputData
, or for short data.y
. Similarly the input signals are obtained by data.InputData
or data.u
.
For a time series (no input channels) use data = iddata(y)
, or let u = []
.
An iddata
object can also contain just an input, by letting y = []
.
The sampling interval can be changed by set(data,
'Ts
',0.3)
or, simpler, by data.Ts = 0.3
.
The input and output channels are given default names like 'y1
', 'y2
', 'u1
','u2
',
etc. The channel names can be set by
(two inputs and one output is this example) and these names will then follow the object and appear in all plots. The names will also be inherited by models that are estimated from the data.
Similarly, channel units can be specified using the properties 'OutputUnit
' and 'InputUnit
'. These units, when specified, will be used in plots.
The time points associated with the data samples are determined by the sampling interval Ts
and the time of the first sample, Tstart
.
The actual time point values are given by the property 'SamplingInstants
', as in
for a plot of the input with correct time points. Autofill is used for all properties, and they are case insensitive.
Manipulating Channels
An easy way to set and retrieve channel properties is to use subscripting. The subscripts are defined as
so dat(:,3,:)
is the data object obtained from dat
by keeping all input channels, but only output channel 3. (Trailing ":
"s can be omitted so dat(:,3,:)= dat(:,3).)
.
The channels can also be retrieved by their names, so that
is the data object where the indicated output channels have been selected and no input channels are selected.
will change samples 101 to 200 of output channels 3 and 4 and input channels 1 and 3 in the iddata
object dat1
to the indicated values from iddata
object dat2
. The names and units of these channels will then also be changed accordingly.
To add new channels, use horizontal concatenation of iddata
objects.
(see "Horizontal Concatenation" below) or add the data record directly. Thus
will add a fifth input to dat
.
Nonequal Sampling
The property 'SamplingInstants'
gives the sampling instants of the data points. It can always be retrieved by get(DAT,'SamplingInstants')
(or dat.s
) and is then computed from dat.Ts
and dat.Tstart
. 'SamplingInstants'
can also be set to an arbitrary vector of the same length as the data, so that nonequal sampling can be handled. Ts
is then automatically set to [ ]. Most of the estimation routines, though, do not handle unequally sampled data.
Multiple Experiments
The iddata
object can also store data from separate experiments. The property 'ExperimentName'
is used to separate the experiments. The number of data as well as the sampling properties can vary from experiment to experiment, but the input and output channels must be the same. (Use NaN
to fill possibly unmeasured channels in certain experiments.) The data records will be cell arrays, where the cells contain data from each experiment.
Multiple experiments can be defined directly by letting the 'y'
and 'u'
properties as well as 'Ts'
and 'Tstart'
be cell arrays.
It is normally easier to create multi-experiment data by merging experiments as in
See the reference page for merge
(data)
. Storing multiple experiments as one iddata
object may be very useful to handle experimental data that has been collected on different occasions, or when a data set has been split up to remove "bad" portions of the data. All the toolbox's routines accept multiple experiment data.
Experiments can be retrieved by the command getexp
. They can also be retrieved by subscripting with a fourth index: dat(:,:,:,3)
is experiment number 3 and dat(:,:,:,{'Day1','Day4'})
retrieves the two experiments with the indicated names.
The subscripting can be combined: dat(1:100,[2,3],[4:8],3)
gives the 100 first samples of output channels 2 and 3 and input channels 4 to 8 of experiment number 3. It can also be used for subassignment, like
which adds the data in dat2
as a new experiment with name 'Run4'
. See iddemo
number 8 for an illustration of how multiple experiments can be used.
iddata Properties
In the list below, N
denotes the number of samples of the signals, ny
the number of output channels, nu
the number of input channels, and Ne
the number of experiments:
Domain
: Assumes the values 'Time
' or 'Frequency
' and denotes whether the data are time domain or frequency domain data.
Name
: An optional name for the data set. An arbitrary string.
OutputData, InputData
: The data matrices y
and u
. In the single experiment case y is an N
-by-ny
matrix and u
is an N
-by-nu
matrix. For multiple experiments y
and u
are 1-by-Ne
cell arrays, with each cell containing the data for the different experiments.
OutputName, InputName
: Cell arrays of length ny
-by-1 and nu
-by-1 containing the names of the output and input channels. If not specified, default names, {'y1
';
'y2
';...}
and {'u1
';
'u2
';...}
are given.
OutputUnit, InputUnit
: Cell arrays of length ny
-by-1 and nu
-by-1 containing the units of the output and input channels.
TimeUnit
: The unit for the sampling instants.
Ts
: Sampling interval. A positive scalar. For multiexperiment data, Ts
is a 1-by-Ne
cell array, with each cell containing the sampling interval of the corresponding experiment. For nonequally sampled data, Ts = []
.
Tstart
: The starting time of the data record. A scalar. For multiexperiment data, Tstart
is a 1-by-Ne
cell array, with each cell containing the starting time for the corresponding experiment
SamplingInstants
: The time values of the sample points. A N
-by-1 vector. For multiple experiment data, SamplingInstants
is a 1-by-Ne
cell array, with each cell containing the sampling instants of the corresponding experiment. For equally sampled data, SamplingInstants
is generated from Ts
and Tstart
.
Period
:
The period of the input. A nu
-by-1 vector, where the k-
th entry contains the period of the k
-th input. Period = inf
means nonperiodic data. For multiexperiment data, Period
is a 1-by-Ne
cell array with each cell containing the period(s) for the input of the corresponding experiment.
InterSample
: Describes the intersample behavior of the input channels. An nu
-by-1 cell array where the (k,1)
element is 'zoh
', 'foh
', or 'bl
', denoting that input number k is piecewise constant, piecewise linear, or band limited. For multiple experiment data, InterSample
is an nu
-by-Ne
cell array.
ExperimentName
: A string containing the name of the experiment. For multiple experiment data ExperimentName
is a 1-by-Ne
cell array with each cell containing the name of the corresponding experiment. It can be freely set, and is by default given names {'Exp1
', 'Exp2
',...}
.
Notes
: An arbitrary field to store extra information and notes about the object.
UserData
: An arbitrary field for any possible use.
Note that all properties can be set or retrieved either by set/get
or by subscripts. Autofill applies to all properties and values, and are case insensitive:. 'y
' and 'u
' can be used as short for 'OutputData
' and 'InputData
'. 'y
' and 'u
' can also replace 'Output
' and 'Input
' in the other properties.
For a complete list of property values, use get(data)
. To see possible value assignments, use set(data)
.
Subreferencing
The samples, outputs and input channels can be referenced according to
Use a colon (:) to denote all samples/channels and the empty matrix ([ ]) to denote no samples/channels. The channels can be referenced by number or by name. For several names, a cell array must be used.
Logical expressions will also work.
will select the samples with time marks between 1.27 and 9.3.
Subreferencing with curly brackets refers to the experiment.
Any subreferenced variable can also be assigned.
Horizontal Concatenation
creates an iddata
object dat
, consisting of the input and output channels in dat1,... datN
. Default channel names ('u1
', 'u2
', 'y1
', 'y2
', etc.) will be changed so that overlaps in names are avoided, and the new channels will be added.
If datk
contains channels with user specified names, that are already present in the channels of Datj, j<k
, these new channels will be ignored.
Vertical Concatenation
creates an iddata
object dat
whose signals are obtained by stacking those of datk
on top of each other. That is
and similarly for the inputs. The datk
objects must all have the same number of channels and experiments.
Online Help Functions
See help iddata
, idprops iddata
, help iddata/subsref
, help iddata/subsasgn
, help iddata/horzcat
, and help iddata/vertcat
.
See Also
![]() | idarx | ident | ![]() |