Products & Services Solutions Academia Support User Community Company

Learn more about System Identification Toolbox   

Simulating and Predicting Model Output

Simulating the Model Output

In this portion of the tutorial, you simulate the model output. You must have already created the continuous-time model midproc2, as described in Estimating Continuous-Time Transfer Functions (Process Models).

Simulating the model output requires the following information:

For example, the following commands use the iddata and idinput commands to construct an input data set, and use sim to simulate the model output:

% Create input for simulation
U = iddata([],idinput([200 2]),'Ts',0.5);
% Simulate the response setting initial conditions
% equal to zero
ysim_1 = sim(midproc2,U,'InitialState','zero')

To match the simulated response of a model to the measured output for the same input, compute the initial states corresponding to the measured data. You can ensure that the simulated response of the model midproc2 provides a good fit to the measured data Zv1 by using findstates(idmodel). The following command estimates the initial states X0est from the data set Zv1:

X0est = findstates(midproc2,Zv1);

Next, simulate the model using the initial states estimated from the data:

Usim = Zv1.u; % Simulation input
ysim_2 = sim(midproc2,Usim,'InitialState',X0est);

Compare the simulated and the measured output on a plot:

figure
plot([ysim_2, Zv1.y])
legend({'model output','measured'})
xlabel('time'), ylabel('Output')

The comparison of simulated and measured output is displayed in the following figure.

Predicting the Future Output

Many control-design applications require you to predict the future outputs of a dynamic system using the past input/output data.

For example, use predict to predict the model response five steps ahead:

predict(midproc2,Ze1,5)

The predicted output is displayed in the following figure.

To compare the predicted output values with the measured output values, use the following command:

compare(Ze1,midproc2,5)

The third argument of compare specifies a five-step-ahead prediction, as shown in the following figure.

Use pe to compute the prediction error Err between the predicted output of midproc2 and the measured output. Then, plot the error spectrum on a Bode plot.

[Err] = pe(midproc2,Zv1);
bode(spa(Err,[],logspace(-2,2,200)),...
         'mode','same','sd',1,'fill')

As shown in the following figure, the prediction errors are plotted with a 1-standard-deviation confidence interval. The errors are greater at high frequencies because of the high-frequency nature of the disturbance.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

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