setmpcsignals

Set signal types in MPC plant model

Description

outPlant = setmpcsignals(inPlant) sets the MPC signal types of inPlant to their default values, returning the result in outPlant. By default, all inputs are manipulated variables, and all outputs are measured outputs.

example

outPlant = setmpcsignals(inPlant,Name,Value) sets the MPC signal types for the input and output signals of the LTI system inPlant, returning the result in outPlant. Specify the signal types and indices using one or more name-value pair arguments. If you do not specify the type for input or output channels, they are configured as manipulated variables and output variables, respectively.

Examples

collapse all

Create a four-input, two output state-space plant model. By default all input signals are manipulated variables and all outputs are measured outputs.

plant = rss(3,2,4);
plant.D = 0;

Configure the plant input/output channels such that:

  • The second and third inputs are measured disturbances.

  • The fourth input is an unmeasured disturbance.

  • The second output is unmeasured.

plant = setmpcsignals(plant,'MD',[2 3],'UD',4,'UO',2);
-->Assuming unspecified input signals are manipulated variables.
-->Assuming unspecified output signals are measured outputs.

Create an MPC controller.

MPCobj = mpc(plant,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.
   for output(s) y1 and zero weight for output(s) y2 

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.

Input Arguments

collapse all

Input plant model, specified as either an LTI model or a linear System Identification Toolbox™ model.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'UnmeasuredDisturbances',[2 3] configures the second and third input arguments as measured disturbances

Manipulated variable indices, specified as the comma-separated pair 'ManipulatedVariables' followed by a vector of positive integers. The maximum index value must not exceed the number of input channels in inPlant. The indices specified using ManipulatedVariables, MeasuredDisturbances, and UnmeasuredDisturbances must not overlap.

Instead of 'ManipulatedVariables', you can use the abbreviation 'MV'.

Measured disturbance indices, specified as the comma-separated pair 'MeasuredDisturbances' followed by a vector of positive integers. The maximum index value must not exceed the number of input channels in inPlant. The indices specified using ManipulatedVariables, MeasuredDisturbances, and UnmeasuredDisturbances must not overlap.

Instead of 'MeasuredDisturbances', you can use the abbreviation 'MD'.

Unmeasured disturbance indices, specified as the comma-separated pair 'UnmeasuredDisturbances' followed by a vector of positive integers. The maximum index value must not exceed the number of input channels in inPlant. The indices specified using ManipulatedVariables, MeasuredDisturbances, and UnmeasuredDisturbances must not overlap.

Instead of 'UnmeasuredDisturbances', you can use the abbreviation 'UD'.

Measured output indices, specified as the comma-separated pair 'MeasuredOutputs' followed by a vector of positive integers. The maximum index value must not exceed the number of output channels in inPlant. The indices specified using MeasuredOutputs and UnmeasuredOutputs must not overlap.

Instead of 'MeasuredOutputs', you can use the abbreviation 'MO'.

Unmeasured output indices, specified as the comma-separated pair 'UnmeasuredOutputs' followed by a vector of positive integers. The maximum index value must not exceed the number of output channels in inPlant. The indices specified using MeasuredOutputs and UnmeasuredOutputs must not overlap.

Instead of 'UnmeasuredOutputs', you can use the abbreviation 'UO'.

Output Arguments

collapse all

Output plant model, returned as a linear dynamic model. outPlant has the specified input and output channel types. Otherwise, outPlant is identical to inPlant.

Tips

In general, set the plant signal types using setmpcsignals before creating your controller object.

If you modify the signal types of the internal plant model of an existing controller, you must ensure that the new input/output channel types are consistent with the following controller properties:

  • Weights

  • ManipulatedVariables

  • OutputVariables

  • DisturbanceVariables

  • Model.Noise

See Also

|

Introduced before R2006a