Documentation Center

  • Trials
  • Product Updates


Simulate response of identified models to arbitrary inputs


  • y = sim(sys,udata)
  • y = sim(sys,udata,opt)
  • [y,y_sd] = sim(___)
  • [y,y_sd,x] = sim(___)


y = sim(sys,udata) simulates the response an identified model, sys, using the input data, udata. Zero initial conditions are used for all model types except idnlgrey where the initial conditions stored internally in the model are used. y is the simulation output.

y = sim(sys,udata,opt) simulates the system response using the option set, opt, to specify simulation behavior.

[y,y_sd] = sim(___) returns the estimated standard deviation, y_sd, for sys.

[y,y_sd,x] = sim(___) returns the state trajectory, x, for state-space models.

Input Arguments


Identified model.

sys may be a linear or nonlinear identified model.


Simulation input data.

Specify data as an iddata object, using only the input channels.

If sys is a linear model, you can use either time- or frequency-domain data. If sys is a nonlinear model, you can use only time-domain data.

For time-domain simulation of discrete-time systems, udata may also be specified as a matrix whose columns correspond to each input channel.

If you do not have data from an experiment, use idinput to generate signals of various characteristics.


Simulation options.

opt is an option set, created using simOptions, that specifies options including:

  • Signal offsets

  • Initial condition handling

  • Additive noise

Output Arguments


Simulated response.

y is an iddata model representing the simulated response for sys using udata as the simulation input.

If udata represents time-domain data, then y is the simulated response for the time vector corresponding to udata.

If udata represents frequency-domain data, then y contains the Fourier transform of the corresponding sampled time-domain output signal. This signal is obtained by the multiplying the frequency response of sys, G(w) and U(w).

For multi-experiment data, y is a corresponding multi-experiment iddata object.


Estimated standard deviation of the simulated response for linear models.

y_sd is derived using first order sensitivity considerations (Gauss approximation formula).

For nonlinear models, y_sd is [].


Estimated state trajectory for state-space models.

Relevant only if sys is a state-space model (idss, idgrey or idnlgrey).

x is an Ns-by-Nx matrix, where Ns is the number of samples and Nx is the number of states.


expand all

Simulate Model Response

Simulate the response of an identified model.

Obtain the identified model.

load iddata2 z2;
sys = tfest(z2,3);

sys is an idtf model that encapsulates the third-order transfer function estimated for the measured data z2.

Simulate the model.


Specify Simulation Option

Simulate the model response of an identified model. Specify simulation options to study the contribution of noise to the simulated model response.

Obtain the identified model.

load iddata2 z2;
sys = tfest(z2,3);


Create a simulation option set that adds noise to the simulated model response.

e = randn(length(z2.u),1);
opt = simOptions('AddNoise',true,'NoiseData',e);

e represents white, Gaussian noise. opt is an option set that specifies the addition of noise data, e, to the simulated model response. You specify the noise data vector, e, that is added to the simulated model response by using the option NoiseData.

Obtain the simulated model response.


Simulate Model Using Initial Conditions Obtained During Estimation

Simulate a model using the same initial conditions as computed during its estimation.

Load data.

load iddata1 z1

Specify the estimation option to estimate the initial state.

estimOpt = ssestOptions('InitialState', 'estimate');

Estimate a state-space model and return the value of the estimated initial state.

[sys, x0] = ssest(z1, 2, estimOpt);

Specify initial conditions for simulation

simOpt = simOptions('InitialCondition', x0);

Simulate the estimated model

Input = z1(:,[],:);
sim(sys, z1, simOpt)


  • Use simsd for a Monte-Carlo method of computing the standard deviation of the response.

  • sim extends lsim to facilitate additional features relevant to identified models:

    • Simulation of nonlinear models

    • Simulation with additive noise

    • Incorporation of signal offsets

    • Computation of response standard deviation (linear models only)

    • Frequency-domain simulation (linear models only)

    • Simulations using different intersample behavior for different inputs

    To obtain the simulated response without any of the preceding operations, use lsim.

More About

expand all


  • You can specify initial conditions for simulation by creating an option set using simOptions and then setting the InitialCondition option appropriately.

    For multi-experiment data, you can configure each experiment's initial conditions individually.

  • You can simulate the initial condition response of time-series models (models with no inputs) using sim. To do so, specify udata as an Ns-by-0 signal, where Ns is the number of samples. As with input-output models, you can study the effect of noise on the response by using the AddNoise and NoiseData simulation options. For more information regarding these simulation options, see simOptions.

    For example:

    load iddata9 z9;
    sys = ar(z9,4,'ls');
    data = iddata([],zeros(512,0),z9.Ts);
    opt = simOptions('AddNoise',true);
    y = sim(sys,data,opt);
  • You can specify the addition of a custom noise signal to the simulated response. To do so, create an option set using simOptions and then set the NoiseData option appropriately.

See Also

| | | | | | |

Was this topic helpful?