Option set for
opt = simOptions;
Create an option set for
sim specifying the following options.
Zero initial conditions
Input offset of 5 for the second input of a two-input model
opt = simOptions('InitialCondition','z','InputOffset',[0; 5]);
Create noise data for a simulation with
500 input data samples and two outputs.
noiseData = randn(500,2);
Create a default option set.
opt = simOptions;
Modify the option set to add the noise data.
opt.AddNoise = true; opt.NoiseData = noiseData;
Use historical input-output data as a proxy for initial conditions when simulating your model.
Load a two-input, one-output data set.
load iddata7 z7
Identify a fifth-order state-space model using the data.
sys = n4sid(z7, 5);
Split the data set into two parts.
zA = z7(1:15); zB = z7(16:end);
Simulate the model using the input signal in
uSim = zB;
Simulation requires initial conditions. The signal values in
zA are the historical data, that is, they are the input and output values for the time immediately preceding data in
zA as a proxy for the required initial conditions.
IO = struct('Input',zA.InputData,'Output',zA.OutputData); opt = simOptions('InitialCondition',IO);
Simulate the model.
ysim = sim(sys,uSim,opt);
To understand how the past data is mapped to the initial states of the model, see Understand Use of Historical Data for Model Simulation.
Load and plot the data.
load iddata1ic z1i plot(z1i)
Examine the initial value of the output data
ystart = z1i.y(1)
ystart = -3.0491
The measured output does not start at 0.
Estimate a second-order transfer function
sys and return the estimated initial condition
[sys,ic] = tfest(z1i,2,1); ic
ic = initialCondition with properties: A: [2x2 double] X0: [2x1 double] C: [0.2957 5.2441] Ts: 0
ic is an
initialCondition object that encapsulates the free response of
sys, in state-space form, to the initial state vector in
sys using the estimation data but without incorporating the initial conditions. Plot the simulated output with the measured output.
y_no_ic = sim(sys,z1i); plot(y_no_ic,z1i) legend('Model Response','Output Data')
The measured and simulated outputs do not agree at the beginning of the simulation.
Incorporate the initial condition into the
simOptions option set.
opt = simOptions('InitialCondition',ic); y_ic = sim(sys,z1i,opt); plot(y_ic,z1i) legend('Model Response','Output Data')
The simulation combines the model response to the input signal with the free response to the initial condition. The measured and simulated outputs now have better agreement at the beginning of the simulation. This initial condition is valid only for the estimation data
comma-separated pairs of
the argument name and
Value is the corresponding value.
Name must appear inside quotes. You can specify several name and value
pair arguments in any order as
'AddNoise',true','InputOffset',[5;0]adds default Gaussian white noise to the response model and specifies an input offset of
5for the first of two model inputs.
'InitialCondition'— Simulation initial conditions
(default) | column vector | matrix |
initialConditionobject | object array | structure | structure array |
Simulation initial conditions, specified as one of the following:
'z' — Zero initial conditions.
Numerical column vector of initial states with length equal to the model order.
For multiexperiment data, specify a matrix with Ne columns, where Ne is the number of experiments, to configure the initial conditions separately for each experiment. Otherwise, use a column vector to specify the same initial conditions for all experiments.
initialCondition object —
initialCondition object that represents a
model of the free response of the system to initial conditions.
For multiexperiment data, specify a
of objects, where Ne
is the number of experiments.
Use this option for linear models only. For an example, see Obtain and Apply Estimated Initial Conditions.
Structure with the following fields, which contain the historical input and output values for a time interval immediately before the start time of the data used in the simulation:
|Input history, specified as a matrix with Nu columns,
where Nu is the number of input channels. For time-series
models, use |
|Output history, specified as a matrix with Ny columns, where Ny is the number of output channels. The number of rows must be greater than or equal to the model order.|
For an example, see Use Historical Data to Specify Initial Conditions for Model Simulation.
For multiexperiment data, configure the initial conditions separately for each experiment by
InitialCondition as a structure
array with Ne elements. To specify the same
initial conditions for all experiments, use a single
The software uses
map the historical data to states. If your model is not
idnlarx, the software first converts the model
to its state-space representation and then maps the data to states.
If conversion of your model to
idss is not possible,
the estimated states are returned empty.
'model' — Use this option
idnlgrey models only. The
software sets the initial states to the values specified in the
of the model
 — Corresponds to zero
initial conditions for all models except
idnlgrey models, the software treats
specifies the initial states as
'X0Covariance'— Covariance of initial states vector
(default) | matrix
Covariance of initial states vector, specified as one of the following:
Positive definite matrix of size Nx-by-Nx, where Nx is the model order.
For multiexperiment data, specify as an Nx-by-Nx-by-Ne matrix, where Ne is the number of experiments.
 — No uncertainty in the
Use this option only for state-space models (
'InitialCondition' is specified as a column
vector. Use this option to account for initial condition uncertainty
when computing the standard deviation of the simulated response of
opt— Option set for
Option set for
sim command, returned as
simOptions option set.