Set or modify MPC object properties
Use the Model Predictive Control Toolbox™
set function to assign property values of an MPC controller (see
mpc for background).
To implement Get/Set interface of standard MATLAB object, see Implement Set/Get Interface for Properties.
set properties of
MPCobj using one or more
Name,Value pair arguments. For example,
set(mpcobj,"ControlHorizon",4) assigns the value
ControlHorizon property of the MPC controller
set( displays all assignable properties
MPCobj and their admissible values.
Change Signal Types of Existing Controller
To modify the signal types for an existing MPC controller, you must simultaneously modify any controller properties that depend on the signal type configuration.
Create a plant model with two outputs, one manipulated variable, one measured disturbance, and two unmeasured disturbances.
plant = rss(3,2,5); plant.D = 0; plant = setmpcsignals(plant,'MV',[1 2],'MD',3,'UD',[4 5]);
Create an MPC controller using this plant.
MPCobj = mpc(plant,0.1);
-->The "PredictionHorizon" property is empty. Assuming default 10. -->The "ControlHorizon" property is empty. Assuming default 2. -->The "Weights.ManipulatedVariables" property is empty. Assuming default 0.00000. -->The "Weights.ManipulatedVariablesRate" property is empty. Assuming default 0.10000. -->The "Weights.OutputVariables" property is empty. Assuming default 1.00000.
Configure the controller properties. For example, set the scaling factors for the disturbance signals.
MPCobj.DisturbanceVariables(1).ScaleFactor = 10; MPCobj.DisturbanceVariables(2).ScaleFactor = 5; MPCobj.DisturbanceVariables(3).ScaleFactor = 20;
Suppose you want to change the second unmeasured disturbance to be a measured disturbance. To do so, you must simultaneously update the
DisturbanceVariables property of the controller, since the order of its entries depend on the disturbance types (measured disturbances followed by unmeasured disturbances).
Create an updated disturbance variable structure array. To do so, move the third element to be the second element.
DV = MPCobj.DisturbanceVariables; DV = [DV(1) DV(3) DV(2)]; DV(2).Name = 'MD2';
To set the internal plant model signal types, obtain the
Model property from the controller, and modify the signal types of its
model = MPCobj.Model; model.Plant = setmpcsignals(model.Plant,'MV',[1 2],'MD',[3 5],'UD',4);
Set the model and disturbance variable properties of the controller to their updated values.
In general, it is best practice to not modify the signal types after controller creation. Instead, create and configure a new controller object with the new signal configuration.
PropertyName — Name of the property to be assigned
character array (default) | string
PropertyName can be the full property name (for example,
'UserData') or any unambiguous case-insensitive abbreviation (for