Main Content

set

Set or modify MPC object properties

Syntax

set(MPCobj,Property,Value)
set(MPCobj,Property1,Value1,Property2,Value2,...)
set(MPCobj,Property)
set(sys)

Description

The set function is used to set or modify the properties of an MPC controller (see mpc for background on MPC properties). set uses property Name,Value pairs to update property values.

set(MPCobj,Property,Value) assigns the value Value to the property of the MPC controller MPCobj specified by the character vector or string Property. Property can be the full property name (for example, 'UserData') or any unambiguous case-insensitive abbreviation (for example, 'user').

set(MPCobj,Property1,Value1,Property2,Value2,...) sets multiple property values with a single statement. Each property Name,Value pair updates one particular property.

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

set(sys) displays all assignable properties of sys 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);
-->The "PredictionHorizon" property of "mpc" object is empty. Trying PredictionHorizon = 10.
-->The "ControlHorizon" property of the "mpc" object is empty. Assuming 2.
-->The "Weights.ManipulatedVariables" property of "mpc" object is empty. Assuming default 0.00000.
-->The "Weights.ManipulatedVariablesRate" property of "mpc" object is empty. Assuming default 0.10000.
-->The "Weights.OutputVariables" property of "mpc" object 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.

See Also

| |

Introduced before R2006a