Example – Simulating a Model Using Simulink® Software

In this example, you set the initial states for simulating a model such that the simulation provides a best fit to measured input-output data.

Suppose you estimate a three-state model M using a multiple-experiment data set Z, which contains data from five experiments—z1, z2, z3, z4, and z5:

Z = merge(z1,z2,z3,z4,z5);
M = n4sid(Z,3);

When a model uses several data sets, the initial-states property stores only the estimated states corresponding to the last data 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 portion of the estimation 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), as follows:

    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 X0est to specify the estimated initial states.

  5. Click OK.

Run the simulation to compare the measured output z2.y to the simulated output.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS