This example shows how to set the initial states for simulating a model such that the simulation provides a best fit to measured input-output data.
To simulate the model using input u2, use x0(:,2) as the initial states. x0(:,2) is computed to maximize the fit between the measured output, y2, and the response of M.
To compute initial states that maximizes the fit to the corresponding output y2, and simulate the model using the second experiment:
Extract the initial states that correspond to the second experiment for simulation:
X0est = x0(:,2);
Open the System Identification Toolbox™ library by typing the following command at the MATLAB® prompt:
Open a new Simulink® model window. Then, drag and drop an Idmodel block from the library into the model window.
Open the Function Block Parameters dialog box by double-clicking the Idmodel block. Specify the following block parameters:
In the Model variable field, type M to specify the estimated model.
In the Initial state field, type X0est to specify the estimated initial states. Click OK.
Drag and drop an Iddata Source block into the model window. Then, configure the model, as shown in the following figure.
Simulate the model for 2 seconds, and compare the simulated output ysim with the measured output ymeasured using the Scope block.