| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → System Identification Toolbox |
| Contents | Index |
| Learn more about System Identification Toolbox |
| On this page… |
|---|
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:
Input values to the model
Initial conditions for the simulation (also called initial states)
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.

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.
Note When you do not specify a third argument, as in Simulating the Model Output, compare assumes an infinite prediction horizon and simulates the model output instead. |

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.

![]() | Estimating Black-Box Polynomial Models | Tutorial – Identifying Nonlinear Black-Box Models Using the GUI | ![]() |

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 |