Main Content


Explicit model predictive controller


Explicit model predictive control uses offline computations to determine all operating regions in which the optimal control moves are determined by evaluating a linear function. Explicit MPC controllers require fewer run-time computations than traditional (implicit) model predictive controllers and are therefore useful for applications that require small sample times.

To implement explicit MPC, first design a traditional (implicit) model predictive controller for your application, and then use this controller to generate an explicit MPC controller for use in real-time control. For more information, see Design Workflow for Explicit MPC.


To create an explicitMPC object:

  1. Create an implicit MPC controller using an mpc object.

  2. Define the operating range for the explicit MPC controller by creating a range structure using the generateExplicitRange function and specifying the bounds using dot notation.

  3. Define the optimization options for converting the implicit controller into an explicit controller using the generateExplicitOptions function.

  4. Create the explicit MPC controller based on the implicit controller, operating range, and optimization options using the generateExplicitMPC function.


expand all

Implicit MPC controller, specified as an mpc object.

Parameter bounds that define the controller operating range, specified as a structure with the following fields.

StateBounds on controller state values
ReferenceBounds on controller reference signal values
MeasuredDisturbanceBounds on measured disturbance values
ManipulatedVariableBounds on manipulated variable values

Define this property using the range input argument to the generateExplicitMPC function, which you create using the generateExplicitRange function and modify using dot notation. For detailed descriptions of the range parameters, see generateExplicitRange.

Optimization options for the conversion computation, specified as a structure with the following fields.

zerotolZero-detection tolerance
removetolRedundant-inequality-constraint detection tolerance
flattolFlat region detection tolerance
normalizetolConstraint normalization tolerance
maxiterNNLSMaximum number of NNLS solver iterations
maxiterQPMaximum number of QP solver iterations
maxiterBSMaximum number of bisection method iterations
polyreductionMethod for removing redundant inequalities

Define this property using the opt input argument to the generateExplicitMPC function, which you create using the generateExplicitOptions function. For detailed descriptions of these options, see generateExplicitOptions.

Piecewise affine solution for the different operating regions, specified as a structure array with Nr elements, where Nr is the number of operating regions.

Each structure element contains fields defining the inequality constraints and control law for each region. For more information on the control law and constraints, see Design Workflow for Explicit MPC.

FRow vector of length Nx-by-Nmv.
GColumn vector of length Nmv
HNc-by-Nx array
KColumn vector of length Nc


  • Nx is the number of independent variables.

  • Nmv is the number of manipulated variables.

  • Nc is the number of inequality constraints for the region.

Flag indicating whether the explicit control law has been simplified using the simplify command. If the control law is simplified, it approximates the implicit MPC controller behavior. If the control law is not simplified, it should reproduce the implicit controller behavior exactly, provided both operate within the bounds described by the range property.

Object Functions

generatePlotParametersParameters for plotSection
getCodeGenerationDataCreate data structures for mpcmoveCodeGeneration
mpcmoveExplicitCompute optimal control using explicit MPC
plotSectionVisualize explicit MPC control law as 2-D sectional plot
simSimulate an MPC controller in closed loop with a linear plant
simplifyReduce explicit MPC controller complexity and memory requirements
sizeSize and order of MPC Controller


collapse all

Generate an explicit MPC controller based upon a traditional MPC controller for a double-integrator plant.

Define the double-integrator plant.

plant = tf(1,[1 0 0]);

Create a traditional (implicit) MPC controller for this plant, with sample time 0.1, a prediction horizon of 10, and a control horizon of 3.

Ts = 0.1;
p = 10;
m = 3;
mpcobj = mpc(plant,Ts,p,m);
-->"Weights.ManipulatedVariables" is empty. Assuming default 0.00000.
-->"Weights.ManipulatedVariablesRate" is empty. Assuming default 0.10000.
-->"Weights.OutputVariables" is empty. Assuming default 1.00000.

To generate an explicit MPC controller, you must specify the ranges of parameters such as state values and manipulated variables. To do so, generate a range structure. Then, modify values within the structure to the desired parameter ranges.

range = generateExplicitRange(mpcobj);
-->Converting the "Model.Plant" property to state-space.
-->Converting model to discrete time.
   Assuming no disturbance added to measured output #1.
-->"Model.Noise" is empty. Assuming white noise on each measured output.
range.State.Min(:) = [-10;-10];
range.State.Max(:) = [10;10];
range.Reference.Min = -2;
range.Reference.Max = 2;
range.ManipulatedVariable.Min = -1.1;
range.ManipulatedVariable.Max = 1.1;

Use the more robust reduction method for the computation. Use generateExplicitOptions to create a default options set, and then modify the polyreduction option.

opt = generateExplicitOptions(mpcobj);
opt.polyreduction = 1;

Generate the explicit MPC controller.

empcobj = generateExplicitMPC(mpcobj,range,opt)
Explicit MPC Controller
Controller sample time:    0.1 (seconds)
Polyhedral regions:        1
Number of parameters:      4
Is solution simplified:    No
State Estimation:          Default Kalman gain
Type 'empcobj.MPC' for the original implicit MPC design.
Type 'empcobj.Range' for the valid range of parameters.
Type 'empcobj.OptimizationOptions' for the options used in multi-parametric QP computation.
Type 'empcobj.PiecewiseAffineSolution' for regions and gain in each solution.

Version History

Introduced in R2014b