User`s guide
Example – Simulating a Model Using Simulink
®
Software
Example – Simulating a Model Using Simulink Software
In this example, you set the initial states for simulating a model such that the
simulation prov ides a b est fit to m easured input-output data.
Suppose you e stimate a thre e-state model
M using a multiple-experiment data
set
Z, which contains data from five experiments—z1, z2, z3, z4,andz5:
Z = merge(z1,z2,z3,z4,z5);
M = n4sid(Z,3);
When a model uses several data sets, the initial-states p roperty stores only
the estimated states corresponding to the last d ata set. In this example,
M.X0
is a vector of length 3 (corresponding to the three states of the model). The
values of
M.X0 are the estimated state values corresponding to z5.
The following procedure describes how to access the initial states that
correspond to
z2 for the simulation, where z2 is a portio n of the estim ation
data
Z.
To compare the measured output from experiment
z2 with the simulated
output:
1 Estimate the initial states using the second experiment as input, that is
Z(z2.u),asfollows:
X0est = findstates(M,getexp(Z,2))
In this case, getexp(Z,2) gets the data in z2.
2 In the Simulink model window, open the Function Block Parameters dialog
box for the
idmodel block.
3 In the idmodel variable field, type M to specify the estimated model.
4 In the Initial states field, type X0e st to specify the estimated initial states.
5 Click OK.
Run the simulation to compare the measured output
z2.y to the simulated
output.
11-9