Skip to Main Content Skip to Search
Product Documentation

sim - Simulate response of identified models to arbitrary inputs

Syntax

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

Description

y = sim(sys,data) simulates the response an identified model, sys, using the input data, data. y is the simulation output.

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

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

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

Tips

Input Arguments

sys

Identified model.

sys may be a linear or nonlinear identified model.

data

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, data 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.

opt

Simulation options.

opt is an option set that specifies the following:

  • signal offsets

  • initial condition handling

  • additive noise

Use simOptions to create the options set.

Output Arguments

y

Simulated response.

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

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

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

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

y_sd

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 [].

x

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.

Examples

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.

sim(sys,z2);

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);

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

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.

sim(sys,z2,opt);

Alternatives

See Also

compare | forecast | idinput | lsim | predict | simOptions | simsd | step

  


Free Control Systems Interactive Kit

Learn more about resources for designing, testing, and implementing control systems.

Get free kit

Trials Available

Try the latest control systems products.

Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS