mpc
Model predictive controller
Description
A model predictive controller uses linear plant, disturbance, and noise models to estimate the controller state and predict future plant outputs. Using the predicted plant outputs, the controller solves a quadratic programming optimization problem to determine control moves.
For more information on the structure of model predictive controllers, see MPC Prediction Models.
Creation
Syntax
Description
creates a model predictive controller object based on the discrete-time prediction model
mpcobj
= mpc(plant
)plant
. The controller, mpcobj
, inherits its
control interval from plant.Ts
, and its time unit from
plant.TimeUnit
. All other controller properties are default values.
After you create the MPC controller, you can set its properties using dot
notation.
If plant.Ts = -1
, you must set the Ts
property of the controller to a positive value before designing and simulating your
controller.
creates a model predictive controller based on the specified plant model and sets the
mpcobj
= mpc(plant
,ts
)Ts
property of the controller. If plant
is:
A continuous-time model, then the controller discretizes the model for prediction using sample time
ts
A discrete-time model with a specified sample time, the controller resamples the plant for prediction using sample time
ts
A discrete-time model with an unspecified sample time (
plant.Ts
=–1
), it inherits the sample timets
when used for predictions.
specifies the following controller properties. If any of these values are omitted or
empty, the default values apply.mpcobj
= mpc(plant
,ts
,P
,M
,W
,MV
,OV
,DV
)
P
sets thePredictionHorizon
property.M
sets theControlHorizon
property.W
sets theWeights
property.MV
sets theManipulatedVariables
property.OV
sets theOutputVariables
property.DV
sets theDisturbanceVariables
property.
creates a model predictive controller object based on the specified prediction model
set, which includes the plant, input disturbance, and measurement noise models along
with the nominal conditions at which the models were obtained. When you do not specify a
sample time, the plant model, mpcobj
= mpc(model
)model.Plant
, must be a discrete-time
model. This syntax sets the Model
property of the
controller.
creates a model predictive controller based on the specified plant model and sets the
mpcobj
= mpc(model
,ts
)Ts
property of the controller to ts
. If
model.Plant
is a discrete-time LTI model with an unspecified
sample time (model.Plant.Ts
= –1
), it inherits the
sample time ts
when used for predictions.
specifies additional controller properties. If any of these values are omitted or empty,
the default values apply.mpcobj
= mpc(model
,ts
,P
,M
,W
,MV
,OV
,DV
)
Input Arguments
Properties
Object Functions
buildMEX | Build MEX file that solves an MPC control problem |
cloffset | Compute closed-loop DC gain from output disturbances to measured outputs assuming constraints are inactive at steady state |
compare | Compare two MPC objects |
generateExplicitMPC | Convert implicit MPC controller to explicit MPC controller |
generatePlotParameters | Parameters for plotSection |
generateExplicitOptions | Optimization options for explicit MPC generation |
generateExplicitRange | Bounds on explicit MPC control law parameters |
get | Get property values from MPC object |
getCodeGenerationData | Create data structures for mpcmoveCodeGeneration |
getEstimator | Obtain Kalman gains and model for estimator design |
getconstraint | Obtain mixed input/output constraints from model predictive controller |
getindist | Retrieve unmeasured input disturbance model |
getname | Retrieve I/O signal names from MPC plant model |
getoutdist | Retrieve unmeasured output disturbance model |
mpcmove | Compute optimal control action and update controller states |
mpcmoveAdaptive | Compute optimal control with prediction model updating |
plot | Plot responses generated by MPC simulations |
review | Examine MPC controller for design errors and stability problems at run time |
sensitivity | Calculate the value of a performance metric and its sensitivity to the diagonal weights of an MPC controller |
set | Set or modify MPC object properties |
setCustomSolver | Configures an MPC object to use the QP solver from Optimization Toolbox as a custom solver |
setEstimator | Modify a model predictive controller’s state estimator |
setconstraint | Set mixed input/output constraints for model predictive controller |
setindist | Modify unmeasured input disturbance model |
setname | Set I/O signal names in MPC plant model |
setoutdist | Modify unmeasured output disturbance model |
setterminal | Terminal weights and constraints |
sim | Simulate an MPC controller in closed loop with a linear plant |
size | Size and order of MPC Controller |
ss | Convert unconstrained MPC controller to state-space linear system form |
tf | Convert unconstrained MPC controller to linear transfer function form |
trim | Compute steady-state value of MPC controller plant model state for given inputs and outputs |
Examples
Algorithms
To minimize computational overhead, model predictive controller creation occurs in two
phases. The first happens at creation when you use the
mpc
function, or when you change a controller property. Creation
includes basic validity and consistency checks, such as signal dimensions and nonnegativity of
weights.
The second phase is initialization, which occurs when you use the object for the first time in a simulation or analytical procedure. Initialization computes all constant properties required for efficient numerical performance, such as matrices defining the optimal control problem and state estimator gains. Additional, diagnostic checks occur during initialization, such as verification that the controller states are observable.
By default, both phases display informative messages in the command window. You can turn
these messages on or off using the mpcverbosity
function.
Alternative Functionality
You can also create model predictive controllers using the MPC Designer app.
Version History
Introduced before R2006aSee Also
Apps
Functions
setmpcsignals
|mpcprops
|mpcverbosity
|review
|cloffset
|getEstimator
|setEstimator
|buildMEX
|mpcmove
|mpcmoveCodeGeneration
|mpcmoveAdaptive
|mpcmoveMultiple
|sim