MPT3 introduces a special object to represent closed-loop systems, consisting of a dynamical system and an MPC controller:
where mpc
represents an MPC controller (either on-line or explicit MPC), and sys
describes the dynamical system.
After a closed-loop object is constructed, you can simulate it by
where x0
is the initial state for the simulation, and Nsim
is the number of simulation steps.
As an example, consider MPC for a linear system {$ x^+ = A x + B u$} with following properties:
Now we want to verify how the controller performs if connected to a different system, say {$ x^+ = A x + B u $} with {$ A = \begin{bmatrix} 1 & 1 \\ 0.2 & 1 \end{bmatrix} $}, {$ B = \begin{bmatrix} 1 \\ 0.8 \end{bmatrix} $}:
NOTE: if you change the controller and/or the system in your MATLAB workspace, the change(s) will automatically propagate to the closed-loop object without the need to re-create it. In other words, in the example above we can as well do:
and the simulation will automatically use the new controller with prediction horizon 10
.