sim
Simulate an MPC controller in closed loop with a linear plant
Syntax
Description
Use the Model Predictive Control Toolbox™
sim function to simulate, in discrete time, the closed-loop or open-loop
response of a plant and an MPC controller with constraints and weights that do not change at
run time. The MPC controller can be implicit, explicit or data-driven, the controlled plant
must be linear and time-invariant, and you must specify the reference and disturbance signals
in advance. For non data-driven controller, by default, the plant used in the simulation is
the one in mpcobj.Model.Plant, but you can use a different plant model to
assess the controller robustness to model mismatch.
To run simulink models programmatically instead, see sim (Simulink).
Classical or Explicit MPC Object
sim(
simulates the closed-loop response to the specified reference signal,
mpcobj,Ns,r)r. The simulation runs in discrete time, with sample time
mpcobj.Ts, for Ns-1 simulation steps, and
simulation results are plotted. The plant model is the one specified in
mpcobj.Model.Plant (which is discretized or resampled, if needed).
The MPC controller mpcobj can be either a classical MPC controller
(mpc) or explicit MPC controller (explicitMPC). If you
omit Ns or r then default values are
used.
sim(___, specifies
additional simulation options. This syntax allows you to alter the default simulation
options, such as initial states, input/output noise, and unmeasured disturbances, plant
mismatch, etc. It also allows you to simulate the plant in open loop. You can use
SimOptions)SimOptions with any of the previous input combinations.
[
suppresses plotting and instead returns:y,t,u,xp,xc,SimOptions] = sim(___)
the sequence of plant outputs
y,the time sequence
t(equally spaced bympcobj.Ts),the manipulated variables
ugenerated by the MPC controller,the sequence
xpof states of the model of the plant used for simulation,the sequence
xmpcof states of the MPC controller (provided by the state observer),and the simulation options object,
SimOptions.
Data-driven MPC Object
sim(
simulates the closed-loop response to the specified reference signal,
ddobj,Ns,r)r. The simulation runs in discrete time, with sample time
ddobj.Ts, for Ns-1 simulation steps, and
simulation results are plotted. The MPC controller ddobj must be a
DataDrivenMPC
object.
sim(___,simulates the
closed-loop response using additional name-value arguments. Use this syntax to specify
input references, past inputs, or past outputs.Name=Value)
Examples
Input Arguments
Name-Value Arguments
Output Arguments
Version History
Introduced before R2006a

