Explicit MPC Controller

Design and simulate explicit model predictive controller


MPC Simulink Library


The Explicit MPC Controller block uses the following input signals:

  • Measured plant outputs (mo)

  • Reference or setpoint (ref)

  • Measured plant disturbance (md), if any

The key difference is that the Explicit MPC Controller block uses a table-lookup control law during each control interval rather than solving a quadratic program. The reduced online computational effort is advantageous in applications requiring a short control interval. The primary trade-off is a heavier offline computational effort to determine the control law and a larger memory footprint to store it. The combinatorial character of this computation restricts its use to applications with relatively few input, output, and state variables, a short prediction horizon, and few output constraints.

The Explicit MPC Controller supports only a subset of optional MPC features, as outlined in the following table.

Supported FeaturesUnsupported Features
  • Custom state estimation (default state estimation uses a static Kalman filter)

  • Outport for state estimation results

  • External manipulated variable feedback signal inport

  • Single-precision block data (default is double precision)

  • Inherited sample time

  • Online tuning (penalty weight adjustments)

  • Online constraint adjustments

  • Online manipulated variable target adjustments

  • Reference and/or measured disturbance previewing

Dialog Box

The Explicit MPC Controller block has the following parameter groupings:


Explicit MPC Controller

An explicitMPC object containing the control law to be used. It must exist in the workspace. Use the generateExplicitMPC command to create this object.

Initial Controller State

An optional mpcstate object specifying the initial controller state. By default the block uses the Model.Nominal property of the controller object.

Required Inports

Measured output or State estimate

If your controller uses default state estimation, this inport is labeled mo. Connect this inport to the measured plant output signals. The MPC controller uses measured plant outputs to improve its state estimates.

To enable custom state estimation, in the General section, select the Use custom state estimation instead of using the built-in Kalman filter. Selecting this option changes the label on this inport to x[k|k]. Connect a signal that provides estimates of the controller state (plant, disturbance, and noise model states). Use custom state estimates when an alternative estimation technique is considered superior to the built-in estimator or when the states are fully measurable.


At each control instant, the ref signal must contain the current reference values (targets or setpoints) for the ny output variables, where ny is the total number of outputs, including measured and unmeasured outputs. Since this block does not support reference previewing, ref cannot be defined as a matrix.

Required Outports

Manipulated Variables

The mv outport provides a signal defining the nu1 manipulated variables for controlling the plant. The controller updates its mv outport at each control instant using the control law contained in the explicit MPC controller object. If the control law evaluation fails, this signal is unchanged; that is, it is held at the previous successful result.

Additional Inports (General Section)

Measured disturbance

Add an inport (md) to which you can connect a vector signal containing nmd elements, where nmd is the number of measured disturbances.

Since this block does not support measured disturbance previewing, md cannot be defined as a matrix.

External manipulated variable

Add an inport (ext.mv) to which you connect a vector signal that contains the actual manipulated variables (MV) used in the plant. The controller uses this signal to update their controller state estimates at each control interval. Using this inport improves state estimation accuracy when the MVs used in the plant differ from the MVs calculated by the block, for example due to signal saturation or an override condition.


Using this option can cause an algebraic loop in the Simulink® model, since there is direct feedthrough from the ext.mv inport to the mv outport. To prevent such algebraic loops, insert a Memory block or Unit Delay block.

For additional information, see the corresponding section of the MPC Controller block reference page.

Additional Outports (General Section)

Status of piecewise affine function evaluation

Add an outport (status) that indicates whether the latest explicit MPC control-law evaluation succeeded. The outport provides a scalar signal that has one of the following values:

  • 1 — Successful explicit control law evaluation

  • 0 — Failure: One or more control law parameters out of range.

  • –1 — Undefined: Control law parameters were within the valid range but an extrapolation was necessary.

If status is either 0 or –1, the mv outport remains at the last known good value.

Region number of evaluated piecewise affine function

Add an outport (region) providing the index of the polyhedral region used in the latest explicit control law evaluation (a scalar). If the control law evaluation fails, the signal at this outport equals zero.

Estimated plant, disturbance, and noise model states

Add an outport (est.state) for the controller state estimates, x[k|k], at each control instant. These estimates include the plant, disturbance, and noise model states.

State Estimation (General Section)

Use custom estimated states instead of measured outputs

Replace mo with the x[k|k] inport for custom state estimation as described in Required Inports.

Others Section

Block data type

Specify the block data type of the manipulated variables as one of the following:

  • double — Double-precision floating point (default)

  • single — Single-precision floating point

    If you are implementing the block on a single-precision target, specify the output data type as single.

For an example of double-precision and single-precision simulation and code generation for an MPC controller, see Simulation and Code Generation Using Simulink Coder.

To view the port data types in a model, in the Simulink Editor, select Display > Signals & PortsPort Data Types.

Inherit sample time

Use the sample time of the parent subsystem as the block sample time. Doing so allows you to conditionally execute this block inside Function-Call Subsystem or Triggered Subsystem blocks. For an example, see Using MPC Controller Block Inside Function-Call and Triggered Subsystems.


You must execute Function-Call Subsystem or Triggered Subsystem blocks at the sample rate of the controller. Otherwise, you can see unexpected results.

To view the sample time of a block, in the Simulink Editor, select Display > Sample Time. Select Colors, Annotations, or All. For more information, see View Sample Time Information (Simulink).

Use external signal to enable controller evaluation

Add an inport (switch) whose input specifies whether the controller evaluates its control law. If the input signal is zero, the controller behaves normally. If the input signal is nonzero, the Explicit MPC Controller block turns off controller evaluation. This action reduces computational effort when the controller output is not needed, such as when the system is operating manually or another controller has taken over. However, the controller continues to update its internal state estimates in the usual way. Thus, it is ready to resume optimization calculations whenever the switch signal returns to zero. While controller evaluation is off, the MPC Controller block passes the current ext.mv signal to the controller output. If the ext.mv inport is not enabled, the controller output is held at the value it had when evaluation was disabled.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

PLC Code Generation
Generate Structured Text code using Simulink® PLC Coder™.

Introduced in R2014b