Main Content

set

Set or modify MPC object properties

Description

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(mpcobj,Name,Value) set properties of mpcobj using one or more Name,Value pair arguments. For example, set(mpcobj,"ControlHorizon",4) assigns the value 3 to the ControlHorizon property of the MPC controller mpcobj.

example

set(mpcobj,PropertyName) displays admissible values for the property specified by the character vector Propertyname. See mpc for an overview of legitimate MPC property values.

set(mpcobj) displays all assignable properties of mpcobj and their admissible values.

Examples

collapse all

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);
-->"PredictionHorizon" is empty. Assuming default 10.
-->"ControlHorizon" is empty. Assuming default 2.
-->"Weights.ManipulatedVariables" is empty. Assuming default 0.00000.
-->"Weights.ManipulatedVariablesRate" is empty. Assuming default 0.10000.
-->"Weights.OutputVariables" 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 Plant element.

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.

set(mpcobj,Model=model,DisturbanceVariables=DV);

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.

Input Arguments

collapse all

Model predictive controller, specified as an MPC controller object. To create an MPC controller, use mpc.

PropertyName can be the full property name (for example, 'UserData') or any unambiguous case-insensitive abbreviation (for example, 'user').

Example: 'PredictionHorizon'

Version History

Introduced before R2006a