Specifications
Design Controller at the Command Line
4-7
T = 26;
r = [2 0];
sim(MPCobj,T,r);
This simulates the closed-loop response for a duration of 26 control intervals with a
setpoint of 2 for the first output (the reactor temperature) and 0 for the second output
(the residual concentration). Recall that the second output's tuning weight is zero (see
the discussion in “Output Weights” on page 3-26), so its setpoint is ignored.
By default, the same linear model is used for controller predictions and the plant, i.e.,
there is no plant/model mismatch. You can alter this as shown in “Simulation Options”
on page 4-7.
When you use the above syntax (no output variables), sim automatically plots the
plant inputs and outputs (not shown, but see Improved Setpoint Tracking for CSTR
Temperature and Plant Inputs for Modified Rate Weight for results of a similar scenario).
Simulation Options
You can modify simulation options using the mpcsimopt function. For example, the code
MPCopts = mpcsimopt;
MPCopts.Constraints = 'off';
sim(MPCobj,T,r,MPCopts)
runs an unconstrained simulation. Comparing to the case described earlier, the
controller's first move now exceeds 4 units (the specified rate constraint).
Other options include the addition of a specified noise sequence to the manipulated
variables or measured outputs, open-loop simulations, a look-ahead option for better
setpoint tracking or measured disturbance rejection, and plant/model mismatch.
For example, the following code defines a new plant model having gains 50% larger than
those in the CSTR model used in the controller, then repeats the above simulation:
Plant = 1.5*CSTR;
MPCopts.Model = Plant;
sim(MPCobj,T,r,MPCopts)
In this case, the plant/model mismatch degrades controller performance, but only
slightly. Degradation can be severe and must be tested on a case-by-case basis.