| System Identification Toolbox™ | ![]() |
y = sim(m,u) y = sim(m,u,'noise') [y, ysd] = sim(m,u,'InitialState',init)
m is any idmodel or idnlmodel object.
u is an iddata object, containing inputs only. (Any outputs are ignored). Both time-domain and frequency-domain signals are supported. The number of input channels in u must either be equal to the number of inputs of the model m or equal to the sum of the number of inputs and noise sources (number of outputs). In the latter case the last inputs in u are regarded as noise sources and a noise-corrupted simulation is obtained. The noise is scaled according to the property m.NoiseVariance in m. To obtain the right noise level according to the model, the noise inputs should be white noise with zero mean and unit covariance matrix. A simpler way of obtaining a noise-corrupted simulation with Gaussian noise is to add the argument 'noise'. If no noise sources are contained in u, a noise-free simulation is obtained. sim applies both to time-domain and frequency-domain iddata objects, but no standard deviations are obtained for frequency-domain signals.
sim returns y, containing the simulated output, as an iddata object.
init gives access to the initial states:
init = 'm' (default) uses the internally stored initial state of model m.
init = 'z' uses zero initial state.
init = x0, where x0 is a column vector of appropriate length, uses this value as the initial state. For multi-experiment inputs, x0 has as many columns as there are experiments to allow for different initial conditions. For a continuous-time model m, x0 is the initial state for this model. Any modifications of the initial state that sampling might require are automatically handled. If m has a non-zero InputDelay, and you need to access the values of the inputs during this delay, you must first apply inpd2nk(m). If m is a continuous-time model, it must first be sampled before inpd2nk can be applied.
The second output argument ysd is the standard deviation of the simulated output. This is not available for frequency-domain data.
u can also be given as a matrix with the number of columns being either the number of inputs in m or the sum of the number of inputs and outputs. Then y and ysd are returned as matrices. Continuous-time models, however, require u to be given as iddata.
If m is a continuous-time model, it is first converted to discrete time with the sampling interval given by ue, taking into account the inter-sample behavior of the input (ue.InterSample).
Simulate a given system m0 (for example, created by idpoly).
e = iddata([],randn(500,1)); u = iddata([],idinput(500,'prbs')); y = sim(m0,[u e]); % iddata object with output y and input u. z = [y u];
The same result is obtained by
u = iddata([],idinput(500,'prbs')); y = sim(m0,u,'noise'); z = [ y u];
or
u = idinput(500,'prbs'); y = sim(m0,u,'noise'); z = iddata(y,u);
Validate a model by comparing a measured output y with one simulated using an estimated model m.
yh = sim(m,u); plot(y,yh)
| compare | |
| idmdlsim | |
| pe | |
| predict | |
| simsd |
![]() | sigmoidnet | sim(idnlarx) | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |