Create MPC controller
MPCobj = mpc(Plant)
MPCobj = mpc(Plant,Ts)
MPCobj = mpc(Plant,Ts,p,m,W,MV,OV,DV)
MPCobj = mpc(Models,Ts,p,m,W,MV,OV,DV)
MPCobj = mpc(Plant)
creates a Model Predictive
Controller object based on a discretetime prediction model. The prediction
model Plant
can be either an LTI model with a specified
sample time or a linear System Identification Toolbox™ model. 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 MPCobj.PropertyName
= PropertyValue
.
MPCobj = mpc(Plant,Ts)
specifies a control
interval of Ts
. If Plant
is
a discretetime LTI model with an unspecified sample time (Plant.Ts
=
–1), it inherits sample time Ts
when used
for predictions.
MPCobj = mpc(Plant,Ts,p,m,W,MV,OV,DV)
specifies
additional controller properties such as the prediction horizon (p
),
control horizon (m
), and input, input increment,
and output weights (W
). You can also set the properties
of manipulated variables (MV
), output variables
(OV
), and input disturbance variables (DV
).
If any of these values are omitted or empty, the default values apply.
MPCobj = mpc(Models,Ts,p,m,W,MV,OV,DV)
creates
a Model Predictive Controller object based on a prediction model set, Models
.
This set includes plant, input disturbance, and measurement noise
models along with the nominal conditions at which the models were
obtained.

Plant model to be used in predictions, specified as an LTI model
( Unless you specify otherwise, controller design assumes that
all plant inputs are manipulated variables and all plant outputs are
measured. Use the If you specify 

Controller sample time (control interval), specified as a positive scalar value. 

Prediction horizon, specified as a positive integer. The control
interval, 

Control horizon, specified as a scalar integer, 

Controller tuning weights, specified as a structure. For details about how to specify this structure, see Weights. 

Bounds and other properties of manipulated variables, specified
as a 1by 

Bounds and other properties of the output variables, specified
as a 1by 

Scale factors and other properties of the disturbance inputs,
specified as a 1by 

Plant, input disturbance, and measurement noise models, along with the nominal conditions at which these models were obtained, specified as a structure. For details about how to specify this structure, see Model. 
To minimize computational overhead, Model Predictive Controller
creation occurs in two phases. The first happens at construction when
you invoke the mpc
command, or when you change
a controller property. Construction involves simple 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
command.
All of the parameters defining the traditional (implicit) MPC control law are stored in an MPC object, whose properties are listed in the following table.
MPC Controller Object
Property  Description 

 Scale factors, input bounds, inputrate bounds, corresponding ECR values, target values, signal names, and units. 
 Scale factors, input bounds, inputrate bounds, corresponding ECR values, target values, signal names, and units. 
 Disturbance scale factors, names, and units 
 Weights used in computing the performance (cost) function 
 Plant, input disturbance, and output noise models, and nominal conditions. 
 Controller sample time 
 Parameters controlling the QP solver 
 Prediction horizon 
 Number of free control moves or vector of blocking moves 
 Creation time 
 Text or comments about the MPC controller object 
 Any additional data 
ManipulatedVariables
(or MV
or Manipulated
or Input
)
is an n_{u}dimensional array
of structures (n_{u} = number
of manipulated variables), one per manipulated variable. Each structure
has the fields described in the following table, where p denotes
the prediction horizon. Unless indicated otherwise, numerical values
are in engineering units.
Manipulated Variable Structure
Field Name  Content  Default 

 Nonnegative scale factor for this MV  1 
 1 to p length vector of lower bounds on this MV 

 1 to p length vector of upper bounds on this MV 

 1 to p length vector of nonnegative
parameters specifying the 

 1 to p length vector of nonnegative
parameters specifying the 

 1 to p length vector of target values for this MV 

 1 to p length vector of lower bounds on the intervaltointerval change for this MV 

 1 to p length vector of upper bounds on the intervaltointerval change for this MV 

 1 to p length vector of nonnegative
parameters specifying the 

 1 to p length vector of nonnegative
parameters specifying the 

 Readonly MV signal name (character vector) 

 Readonly MV signal units (character vector) 

Note Rates refer to the difference Δu(k)=u(k)u(k1). Constraints and weights based on derivatives du/dt of continuoustime input signals must be properly reformulated for the discretetime difference Δu(k), using the approximation du/dt ≅ Δu(k)/T_{s}. 
OutputVariables
(or OV
or Controlled
or Output
)
is an n_{y}dimensional array
of structures (n_{y} = number
of outputs), one per output signal. Each structure has the fields
described in the following table. p denotes the
prediction horizon. Unless specified otherwise, values are in engineering
units.
Output Variable Structure
Field Name  Content  Default 

 Nonnegative scale factor for this OV  1 
 1 to p length vector of lower bounds on this OV 

 1 to p length vector of upper bounds on this OV 

 1 to p length vector of nonnegative
parameters specifying the 

 1 to p length vector of nonnegative
parameters specifying the 

 Readonly OV signal name (character vector) 

 Readonly OV signal units (character vector) 

In order to reject constant disturbances due, for instance, to gain nonlinearities, the default measured output disturbance model used in Model Predictive Control Toolbox™ software is integrated white noise (see Output Disturbance Model).
DisturbanceVariables
(or DV
or Disturbance
)
is an (n_{v}+n_{d})dimensional
array of structures (n_{v} =
number of measured input disturbances, n_{d} =
number of unmeasured input disturbances). Each structure has the fields
described in the following table.
Disturbance Variable Structure
Field Name  Content  Default 

 Nonnegative scale factor for this DV  1 
 Readonly DV signal name (character vector) 

 Readonly DV signal units (character vector) 

The order of the disturbance signals within the array DV
is
the following: the first n_{v} entries
relate to measured input disturbances, the last n_{d} entries
relate to unmeasured input disturbances.
Weights
is
the structure defining the QP weighting matrices. It contains four
fields. The values of these fields depend on whether you are using
the standard quadratic cost function (see Standard Cost Function)
or the alternative cost function (see Alternative Cost Function).
The following table lists the content of the four structure fields. In the table, p denotes the prediction horizon, n_{u} the number of manipulated variables, and n_{y} the number of output variables.
For the MV
, MVRate
and OV
weights,
if you specify fewer than p rows, the last row
repeats automatically to form a matrix containing p rows.
Weights for the Standard Cost Function
Field Name (Abbreviations)  Content  Default (dimensionless) 

 (1 to p)byn_{u} dimensional array of nonnegative MV weights 

 (1 to p)byn_{u} dimensional array of MVincrement weights 

 (1 to p)byn_{y} dimensional array of OV weights 

 Scalar weight on the slack variable ɛ used for constraint softening 

Note
If all 
You can specify offdiagonal Q and R weight
matrices in the cost function. To do so, define the fields ManipulatedVariables
, ManipulatedVariablesRate
,
and OutputVariables
as cell arrays, each containing
a single positivesemidefinite matrix of the appropriate size. Specifically, OutputVariables
must
be a cell array containing the n_{y}byn_{y} Q matrix, ManipulatedVariables
must
be a cell array containing the n_{u}byn_{u} R_{u} matrix,
and ManipulatedVariablesRate
must be a cell array
containing the n_{u}byn_{u} R_{Δu} matrix
(see Alternative Cost Function and
the mpcweightsdemo
example). You can use diagonal
weight matrices for one or more of these fields. If you omit a field,
the MPC controller uses the defaults shown in the table above.
For example, you can specify offdiagonal weights, as follows
MPCobj.Weights.OutputVariables = {Q}; MPCobj.Weights.ManipulatedVariables = {Ru}; MPCobj.Weights.ManipulatedVariablesRate = {Rdu};
where Q
= Q. Ru
= R_{u},
and Rdu
= R_{Δu} are
positive semidefinite matrices.
Note
You cannot specify nondiagonal weights that vary at each prediction
horizon step. The same 
The property Model
specifies plant, input
disturbance, and output noise models, and nominal conditions, according
to the model setup described in Controller State Estimation. It is a 1D structure containing
the following fields.
Models Used by MPC
Field Name  Content  Default  

 LTI model or identified linear model of the plant  No default  
 LTI model describing expected unmeasured input disturbances  [ ] (By default, input disturbances are expected to be integrated white noise. To model the signal, an integrator with dimensionless unity gain is added for each unmeasured input disturbance, unless the addition causes the controller to lose state observability. In that case, the disturbance is expected to be white noise, and so, a dimensionless unity gain is added to that channel instead.)  
 LTI model describing expected noise for output measurements  [ ] (By default, measurement noise is expected to be white noise with unit variance. To model the signal, a dimensionless unity gain is added for each measured channel.)  
 Structure containing the state, input, and output values
where  The default values of the fields are shown in the following table:

Note
Direct feedthrough from manipulated variables to any output
in 
Specify input and output signal types via the InputGroup
and OutputGroup
properties
of Model.Plant
, or, more conveniently, use the setmpcsignals
command. Valid signal types
are listed in the following tables.
Input Groups in Plant Model
Name (Abbreviations)  Value 

 Indices of manipulated variables in 
 Indices of measured disturbances in 
 Indices of unmeasured disturbances in 
Output Groups in Plant Model
Name (Abbreviations)  Value 

 Indices of measured outputs in 
 Indices of unmeasured outputs in 
By default, all Model.Plant
inputs are manipulated
variables, and all outputs are measured.
The structure Nominal
contains the values
(in engineering units) for states, inputs, outputs, and state derivatives/differences
at the operating point where Model.Plant
applies.
This point is typically a linearization point. The fields are reported
in the following table (see also MPC Modeling).
Nominal Values at Operating Point
Field  Description  Default 

 Plant state at operating point 

 Plant input at operating point, including manipulated variables and measured and unmeasured disturbances 

 Plant output at operating point 

 For continuoustime models, 

Sample time of the MPC controller. By default, if Model.Plant
is
a discretetime model, Ts = Model.Plant.ts
. For
continuoustime plant models, specify a controller Ts
.
The Ts
measurement unit is inherited from Model.Plant.TimeUnit
.
Parameters for the QP optimization.Optimizer
is
a structure with the following fields:
Optimizer Properties
Field  Description  Default 

 Maximum number of iterations allowed in the QP solver, specified as one of the following:


 Minimum value allowed for 

 Flag indicating whether to use a custom QP solver, specified
as a logical value. If 

Note:
The default 
PredictionHorizon
is the integer number of
prediction horizon steps. The control interval, Ts
,
determines the duration of each step. The default value is 10 + maximum
intervals of delay (if any).
ControlHorizon
is either a number of free
control moves, or a vector of blocking moves (see Optimization Variables). The default value is 2.
History
stores the time the MPC controller
was created (read only).
Notes
stores text or comments as a cell array
of character vectors.
Any additional data stored within the MPC controller object.
get
 mpcprops
 mpcverbosity
 set
 setmpcsignals