System Identification Toolbox
sim

Simulate linear models.

Syntax

• ```y = sim(m,ue)
[y, ysd] = sim(m,ue,init)
```

Description

`m `is an arbitrary `idmodel` object.

`ue` is an `iddata` object, containing inputs only. The number of input channels in `ue `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 `ue` are regarded as noise sources and a noise-corrupted simulation is obtained. The noise is scaled according to the property `m.NoiseVariance` in `m`, so in order to obtain the right noise level according to the model, the noise inputs should be white noise with zero mean and unit covariance matrix. If no noise sources are contained in `ue`, a noise-free simulation is obtained.

`sim` returns `y` containing the simulated output, as an `iddata` object.

`init` gives access to the initial states:

• `init = 'm`' (default) uses the model `m`'s internally stored initial state.
• `init = 'z`' uses zero initial state.
• `init = x0`, where `x0` is a column vector of appropriate length uses this value as the initial state.

The second output argument `ysd` is the standard deviation of the simulated output.

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 intersample behavior of the input (`ue.InterSample`). See the sectionDiscrete and Continuous Time Models in the "Tutorial".

Examples

Simulate a given system `m0` (for example created by id`poly`).

• ```e = iddata([],randn(500,1));
u = iddata([],idinput(500,'prbs'));
y = sim(m0,[u e]);
z = [y u]; % An iddata object with y as output and u as input.
```

Validate a model by comparing a measured output `y` with one simulated using an estimated model `m`.

• ```yh = sim(m,u);
plot(y,yh)
```