Simulate model predictive controller

**Library:**Model Predictive Control Toolbox

The MPC Controller block receives the current measured output signal
(`mo`

), reference signal (`ref`

), and optional measured
disturbance signal (`md`

). The block computes the optimal manipulated
variable (`mv`

) by solving a quadratic programming problem using either the
default KWIK solver or a custom QP solver. For more information, see QP Solvers.

To use the block in simulation and code generation, you must specify an
`mpc`

object, which defines a model predictive controller. This
controller must have already been designed for the plant that it controls.

Because the MPC Controller block uses MATLAB Function
blocks, it requires compilation each time you change the MPC object and block. Also, because
MATLAB^{®} does not allow compiled code to reside in any MATLAB product folder, you must use a non-MATLAB folder to work on your Simulink^{®} model when you use MPC blocks.

`ref`

— Model output reference valuesrow vector | matrix

Plant output reference values, specified as a row vector signal or matrix signal.

To use the same reference values across the prediction horizon, connect **ref** to a row vector signal with *N _{Y}* elements, where

To vary the references over the prediction horizon (previewing) from time
*k*+1 to time *k*+*p*, connect
**ref** to a matrix signal with
*N _{y}* columns and up to

`mo`

— Measured outputvector

Measured output signals, specified as a vector signal. The MPC controller uses the measured plant outputs to improve its state estimates. If your controller uses default state estimation, you must connect the measured plant outputs to the **mo** input port. If your controller uses custom state estimation, you must connect a signal to the **x[k|k]** input port.

To enable this port, clear the **Use custom state estimation instead of using the
built-in Kalman filter** parameter.

`x[k|k]`

— Custom state estimatevector

Custom state estimate, specified as a vector signal. The MPC controller uses the connected state estimates instead of estimating the states using its build-in estimator. If your controller uses custom state estimation, you must connect current state estimates to the **x[k|k]** input port. If your controller uses default state estimation, you must connect a signal to the **mo** input port.

Even though measurement noise states (if any) are not
used in MPC optimization, the custom state vector
must contain all the states defined in the
`mpcstate`

object of the
controller, including the 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.

To enable this port, select the **Use custom state estimation instead of using the
built-in Kalman filter** parameter.

`md`

— inputrow vector | matrix

If your controller model has measured disturbances, enable this input port, and connect a row vector or matrix signal. If your controller has measured disturbances, you must enable this port.

To use the same measured disturbance values across the prediction horizon, connect **md** to a row vector signal with *N _{md}* elements, where

To vary the disturbances over the prediction horizon (previewing) from time
*k* to time *k*+*p*, connect
**md** to a matrix signal with
*N _{md}* columns and up to

`ext.mv`

— Control signals used in plant at previous control intervalvector

Control signals used in plant at previous control interval, specified as a vector signal of
length*N _{mv}*, where

You know your controller is not always in control of the plant

When the actual MV signals applied to the plant can potentially differ from the values generated by the controller, such as control signal saturation

Controller state estimation assumes that the MV is piecewise constant. Therefore, at time *t _{k}*, the

Connect

**ext.mv**to the MV signals actually applied to the plant in the previous control interval. Typically, these MV signals are the values generated by the controller, though this is not always the case. For example, if your controller is offline and running in tracking mode; that is, the controller output is not driving the plant, then feeding the actual control signal to**ext.mv**can help achieve bumpless transfer when the controller is switched back online.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 an example that uses the external manipulated variable input port for bumpless transfer, see Switch Controller Online and Offline with Bumpless Transfer.

To enable this port, select the **External manipulated variable** parameter.

`switch`

— Enable or disable optimizationscalar

To turn off the controller optimization calculations, connect
**switch** to a nonzero signal.

Disabling optimization calculations 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. Therefore, it is ready to resume optimization calculations whenever the
**switch** signal returns to zero. While controller optimization is
off, the 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 optimization was disabled.

For an example that uses the external manipulated variable input port for bumpless transfer, see Switch Controller Online and Offline with Bumpless Transfer.

To enable this port, select the **Use external signal to enable or disable optimization** parameter.

`mv.target`

— Manipulated variable targetsrow vector | array

To specify manipulated variable targets, enable this input port, and connect a row vector or matrix signal. To make a given manipulated variable track its specified target value, you must also specify a nonzero tuning weight for that manipulated variable.

To use the same manipulated variable targets across the prediction horizon, connect **mv.target** to a row vector signal with *N _{mv}* elements, where

To vary the targets over the prediction horizon (previewing) from time *k* to time *k*+*p*-1, connect **mv.target** to a matrix signal with *N _{mv}* columns and up to

To enable this port, select the **Targets for manipulated variables** parameter.

`ymin`

— Minimum output variable constraintsrow vector

Minimum output variable constraints, specified as a row vector that contains
*N _{y}* finite values, where

`i`

th
element of `OutputVariables(i).Min`

property of the controller at run
time.If an output variable does not have a lower bound specified in the controller object, then the corresponding connected signal value is ignored.

If this parameter is not selected, the block uses the constant constraint values
stored within its `mpc`

object.

You cannot specify time-varying constraints at run time using a matrix signal.

If the `OutputVariables(i).Min`

property of the controller is
specified as a vector (that is, the constraint varies over the prediction horizon),
the `i`

th element of **ymin** replaces the first
finite entry in this vector, and the remaining values shift to retain the same
constraint profile.

To enable this port, select the **Lower OV limits** parameter.

`ymax`

— Maximum output variable constraintsrow vector

Maximum output variable constraints, specified as a row vector that contains
*N _{y}* finite values, where

`i`

th
element of `OutputVariables(i).Max`

property of the controller at run
time.If an output variable does not have an upper bound specified in the controller object, then the corresponding connected signal value is ignored.

If this parameter is not selected, the block uses the constant constraint values
stored within its `mpc`

object.

You cannot specify time-varying constraints at run time using a matrix signal.

If the `OutputVariables(i).Max`

property of the controller is
specified as a vector (that is, the constraint varies over the prediction horizon),
the `i`

th element of **ymax** replaces the first
finite entry in this vector, and the remaining values shift to retain the same
constraint profile.

To enable this port, select the **Upper OV limits** parameter.

`umin`

— Minimum manipulated variable constraintsrow vector

Minimum manipulated variable constraints, specified as a row vector that contains
*N _{mv}* finite values, where

`i`

th element of `ManipulatedVariables(i).Min`

property of the controller at run
time.If a manipulated variable does not have a lower bound specified in the controller object, then the corresponding connected signal value is ignored.

If this parameter is not selected, the block uses the constant constraint values
stored within its `mpc`

object.

You cannot specify time-varying constraints at run time using a matrix signal.

If the `ManipulatedVariables(i).Min`

property of the controller
is specified as a vector (that is, the constraint varies over the prediction
horizon), the `i`

th element of **umin** replaces
the first finite entry in this vector, and the remaining values shift to retain the
same constraint profile.

To enable this port, select the **Lower MV limits** parameter.

`umax`

— Maximum manipulated variable constraintsrow vector

Maximum manipulated variable constraints, specified as a row vector that contains
*N _{mv}* finite values, where

`i`

th element of `ManipulatedVariables(i).Max`

property of the controller at run
time.If a manipulated variable does not have an upper bound specified in the controller object, then the corresponding connected signal value is ignored.

`mpc`

object.

You cannot specify time-varying constraints at run time using a matrix signal.

If the `ManipulatedVariables(i).Max`

property of the controller
is specified as a vector (that is, the constraint varies over the prediction
horizon), the `i`

th element of **umax** replaces
the first finite entry in this vector, and the remaining values shift to retain the
same constraint profile.

To enable this port, select the **Upper MV limits** parameter.

`E`

— Manipulated variable constraint matrixmatrix

Manipulated variable constraint matrix, specified as an
*N _{c}*-by-

If you define `E`

in the `mpc`

object, you must
connect a signal to the **E** input port. Otherwise, connect a zero
matrix with the correct size.

To specify run-time mixed input/output constraints, use the **E** input port
along with the **F**, **G**, and
**S** ports. These constraints replace the mixed input/output
constraints previously set using `setconstraint`

. For more information on mixed input/output constraints,
see Constraints on Linear Combinations of Inputs and Outputs.

The number of mixed input/output constraints cannot change at run time. Therefore,
*N _{c}* must match the number of rows in
the

`E`

matrix you specified using
`setconstraint`

.To enable this port, select the **Custom constraints** parameter.

`F`

— Controlled output constraint matrixmatrix

Controlled output constraint matrix, specified as an
*N _{c}*-by-

`F`

in the `mpc`

object, you must connect a signal to the To specify run-time mixed input/output constraints, use the **F** input port
along with the **E**, **G**, and
**S** ports. These constraints replace the mixed input/output
constraints previously set using `setconstraint`

. For more information on mixed input/output constraints,
see Constraints on Linear Combinations of Inputs and Outputs.

The number of mixed input/output constraints cannot change at run time. Therefore,
*N _{c}* must match the number of rows in
the

`F`

matrix you specified using
`setconstraint`

.To enable this port, select the **Custom constraints** parameter.

`G`

— Custom constraint vectorrow vector

Custom constraint vector, specified as a row vector signal of length
*N _{c}*, where

`G`

in the `mpc`

object,
you must connect a signal to the To specify run-time mixed input/output constraints, use the **G** input port
along with the **E**, **F**, and
**S** ports. These constraints replace the mixed input/output
constraints previously set using `setconstraint`

. For more information on mixed input/output constraints,
see Constraints on Linear Combinations of Inputs and Outputs.

The number of mixed input/output constraints cannot change at run time. Therefore,
*N _{c}* must match the number of rows in
the

`G`

matrix you specified using
`setconstraint`

.To enable this port, select the **Custom constraints** parameter.

`S`

— Measured disturbance constraint matrixmatrix

Measured disturbance constraint matrix, specified as an
*N _{c}*-by-

`S`

in the
`mpc`

object, you must connect a signal to the
To specify run-time mixed input/output constraints, use the **S** input port
along with the **E**, **F**, and
**G** ports. These constraints replace the mixed input/output
constraints previously set using `setconstraint`

. For more information on mixed input/output constraints,
see Constraints on Linear Combinations of Inputs and Outputs.

The number of mixed input/output constraints cannot change at run time. Therefore,
*N _{c}* must match the number of rows in
the

`G`

matrix you specified using
`setconstraint`

.To enable this port, select the **Custom constraints** parameter. This port is added only if the `mpc`

object has measured disturbances.

`y.wt`

— Output variable tuning weightsrow vector | matrix

To specify run-time output variable tuning weights, enable this input port. If this port is disabled, the block uses the tuning weights specified in the `Weights.OutputVariables`

property of its controller object. These tuning weights penalize deviations from output references.

If the MPC controller object uses constant output tuning weights over the prediction horizon, you can specify only constant output tuning weights at runtime. Similarly, if the MPC controller object uses output tuning weights that vary over the prediction horizon, you can specify only time-varying output tuning weights at runtime

To use constant tuning weights over the prediction horizon, connect **y.wt**
to a row vector signal with *N _{y}* elements, where

To vary the tuning weights over the prediction horizon from time *k*+1 to time *k*+*p*, connect **y.wt** to a matrix signal with *N _{y}* columns and up to

To enable this port, select the **OV weights** parameter.

`u.wt`

— Manipulated variable tuning weightsrow vector | matrix

To specify run-time manipulated variable tuning weights, enable this input port. If
this port is disabled, the block uses the tuning weights specified in the
`Weights.ManipulatedVariables`

property of its controller object.
These tuning weights penalize deviations from MV targets.

If the MPC controller object uses constant manipulated variable tuning weights over the prediction horizon, you can specify only constant manipulated variable tuning weights at runtime. Similarly, if the MPC controller object uses manipulated variable tuning weights that vary over the prediction horizon, you can specify only time-varying manipulated variable tuning weights at runtime

To use the same tuning weights over the prediction horizon, connect
**u.wt** to a row vector signal with
*N _{mv}* elements, where

To vary the tuning weights over the prediction horizon from time *k*
to time *k*+*p*-1, connect **u.wt**
to a matrix signal with *N _{mv}* columns and up to

To enable this port, select the **MV weights** parameter.

`du.wt`

— Manipulated variable rate tuning weightsrow vector | matrix

To specify run-time manipulated variable rate tuning weights, enable this input port. If this port is disabled, the block uses the tuning weights specified in the `Weights.ManipulatedVariablesRate`

property of its controller object. These tuning weights penalize large changes in control moves.

If the MPC controller object uses constant manipulated variable rate tuning weights over the prediction horizon, you can specify only constant manipulated variable tuning rate weights at runtime. Similarly, if the MPC controller object uses manipulated variable rate tuning weights that vary over the prediction horizon, you can specify only time-varying manipulated variable rate tuning weights at runtime

To use the same tuning weights over the prediction horizon, connect **du.wt** to a row vector signal with *N _{mv}* elements, where

To vary the tuning weights over the prediction horizon from time *k* to time *k*+*p*-1, connect **du.wt** to a matrix signal with *N _{mv}* columns and up to

To enable this port, select the **MVRate weights** parameter.

`ecr.wt`

— Slack variable tuning weightscalar

To specify a run-time slack variable tuning weight, enable this input port and connect a scalar signal. If this port is disabled, the block uses the tuning weight specified in the `Weights.ECR`

property of its controller object.

The slack variable tuning weight has no effect unless your controller object defines soft constraints whose associated ECR values are nonzero. If there are soft constraints, increasing the **ecr.wt** value makes these constraints relatively harder. The controller then places a higher priority on minimizing the magnitude of the predicted worst-case constraint violation.

To enable this port, select the **ECR weight** parameter.

`p`

— Prediction horizonpositive integer

Prediction horizon, specified as positive integer signal. The prediction horizon signal value must be less than or equal to the **Maximum prediction horizon** parameter.

At run time, the values of `p`

overrides the default prediction horizon specified in the controller object. For more information, see Adjust Horizons at Run Time.

To enable this port, select the **Adjust prediction horizon and control horizon at run time** parameter.

`m`

— Control horizonpositive integer | vector

Control horizon, specified as one of the following:

Positive integer signal less than or equal to the prediction horizon.

Vector signal of positive integers specifying blocking interval lengths. For more information, see Manipulated Variable Blocking.

At run time, the values of `m`

overrides the default control horizon specified in the controller object. For more information, see Adjust Horizons at Run Time.

To enable this port, select the **Adjust prediction horizon and control horizon at run time** parameter.

`mv`

— Optimal manipulated variable control actioncolumn vector

Optimal manipulated variable control action, output as a column vector signal of length *N _{mv}*, where

If the solver converges to a local optimum solution (**qp.status** is positive), then **mv** contains the optimal solution.

If the solver fails (**qp.status** is negative), then **mv** remains at its most recent successful solution; that is, the controller output freezes.

If the solver reaches the maximum number of iterations without finding an optimal solution
(**qp.status** is zero) and the
`Optimization.UseSuboptimalSolution`

property of the controller
is:

`true`

, then**mv**contains the suboptimal solution`false`

, then**mv**then**mv**remains at its most recent successful solution

`cost`

— Objective function costnonnegative scalar

Objective function cost, output as a nonnegative scalar signal. The cost quantifies the degree to which the controller has achieved its objectives. The cost value is calculated using the scaled MPC cost function in which every term is offset-free and dimensionless.

The cost value is only meaningful when the **qp.status** output is nonnegative.

To enable this port, select the **Optimal cost** parameter.

`qp.status`

— Optimization statusinteger

Optimization status, output as an integer signal.

If the controller solves the QP problem for a given control interval, the
**qp.status** output returns the number of QP solver iterations
used in computation. This value is a finite, positive integer and is proportional to the
time required for the calculations. Therefore, a large value means a relatively slow
block execution for this time interval.

The QP solver can fail to find an optimal solution for the following reasons:

**qp.status**=`0`

— The QP solver cannot find a solution within the maximum number of iterations specified in the`mpc`

object. In this case, if the`Optimizer.UseSuboptimalSolution`

property of the controller is`false`

, the block holds its**mv**output at the most recent successful solution. Otherwise, it uses the suboptimal solution found during the last solver iteration.**qp.status**=`-1`

— The QP solver detects an infeasible QP problem. See Monitoring Optimization Status to Detect Controller Failures for an example where a large, sustained disturbance drives the output variable outside its specified bounds. In this case, the block holds its**mv**output at the most recent successful solution.**qp.status**=`-2`

— The QP solver has encountered numerical difficulties in solving a severely ill-conditioned QP problem. In this case, the block holds its**mv**output at the most recent successful solution.

In a real-time application, you can use **qp.status** to set an alarm or take other special action.

To enable this port, select the **Optimization status** parameter.

`est.state`

— Estimated controller statesvector

Estimated controller states at each control instant, output as a vector signal. The estimated states include the plant, disturbance, and noise model states.

To enable this port, select the **Estimated controller states**
parameter.

`mv.seq`

— Optimal manipulated variable sequencematrix

Optimal manipulated variable sequence, returned as a matrix signal with *p*+1 rows and *N _{mv}* columns, where

The first *p* rows of **mv.seq** contain the
calculated optimal manipulated variable values from current time *k* to
time *k*+*p*-1. The first row of
**mv.seq** contains the current manipulated variable values (output
**mv**). Since the controller does not calculate optimal control
moves at time *k*+*p*, the final two rows of **mv.seq** are
identical.

To enable this port, select the **Optimal control sequence** parameter.

`x.seq`

— Optimal prediction model state sequencematrix

Optimal prediction model state sequence, returned as a matrix signal with *p*+1 rows and *N _{x}* columns, where

The first *p* rows of **x.seq** contain the
calculated optimal state values from current time *k* to time
*k*+*p*-1. The first row of
**x.seq** contains the current estimated state values. Since the
controller does not calculate optimal states at time *k*+*p*, the final two rows of **x.seq** are
identical.

To enable this port, select the **Optimal state sequence** parameter.

`y.seq`

— Optimal output variable sequencematrix

Optimal output variable sequence, returned as a matrix signal with *p*+1 rows and *N _{y}* columns, where

The first *p* rows of **y.seq** contain the
calculated optimal output values from current time *k* to time
*k*+*p*-1. The first row of
**y.seq** is computed based on the current estimated states and the
current measured disturbances (first row of input **md**). Since the
controller does not calculate optimal output values at time *k*+*p*, the final two rows of **y.seq** are
identical.

To enable this port, select the **Optimal output sequence** parameter.

`MPC Controller`

— Controller object`mpc`

object nameSpecify an `mpc`

object that defines an implicit MPC
controller by entering the name of an `mpc`

object from the
MATLAB workspace.

Block Parameter:
`mpcobj` |

Type: string, character vector |

Default:
`""` |

`Initial Controller State`

— Initial state`mpcstate`

object nameSpecify the initial controller state. If you leave this parameter blank, the block uses the
nominal values defined in the `Model.Nominal`

property of the
`mpc`

object. To override the default, create an `mpcstate`

object in your workspace, and enter its name in the
field.

Use this parameter make the controller states reflect the true plant environment at
the start of your simulation to the best of your knowledge. This initial states can
differ from the nominal states defined in the `mpc`

object.

If custom state estimation is enabled, the block ignores **Initial Controller
State** parameter.

Block Parameter: `x0` |

Type: string, character vector |

Default: `""` |

`Design`

— Interactively design controllerbutton

To interactively modify the controller specified using the **MPC
Controller** parameter, open the **MPC
Designer** app by clicking **Design**. For example, you
can:

Import a new prediction model.

Change horizons, constraints, and weights.

Evaluate MPC performance with a linear plant.

Export the updated controller to the MATLAB workspace.

If you have an existing `mpc`

object in the MATLAB workspace, specify the name of that object using the **MPC
Controller** parameter.

If you do not have an existing `mpc`

object in the MATLAB workspace, leave the **MPC Controller** parameter empty.
With the MPC Controller block connected to the plant, open **MPC
Designer** by clicking **Design**. Using the app,
linearize the Simulink model at a specified operating point, and design your controller. To use
this design approach, you must have Simulink
Control Design™ software. For more information, see Design MPC Controller in Simulink and Linearize Simulink Models Using MPC Designer.

`Review`

— Review controller for stability and robustness issuesbutton

Once you specify a controller using the **MPC Controller**
parameter, you can review your design for run-time stability and robustness issues by
clicking **Review**. For more information, see Review Model Predictive Controller for Stability and Robustness Issues.

`Measured disturbances`

— Add measured disturbance input porton (default) | off

If your controller has measured disturbances, you must select this parameter to add the **md** output port to the block.

Block Parameter: `md_inport` |

Type: string, character vector |

Values: `"off"` , `"on"` |

Default:
`"on"` |

`External manipulated variable`

— Add external manipulated variable input portoff (default) | on

Select this parameter to add the **ext.mv** input port to the block.

Block Parameter: `mv_inport` |

Type: string, character vector |

Values: `"off"` , `"on"` |

Default: `"off"` |

`Targets for manipulated variables`

— Add manipulated variable target input portoff (default) | on

Select this parameter to add the **mv.target** input port to the block.

Block Parameter: `uref_inport` |

Type: string, character vector |

Values: `"off"` , `"on"` |

Default: `"off"` |

`Optimal cost`

— Odd optimal cost output portoff (default) | on

Select this parameter to add the **cost** output port to the block.

Block Parameter: `return_cost` |

Type: string, character vector |

Values: `"off"` , `"on"` |

Default: `"off"` |

`Optimization status`

— Add optimization status output portoff (default) | on

Select this parameter to add the **qp.status** output port to the block.

Block Parameter: `return_qpstatus` |

Type: string, character vector |

Values: `"off"` , `"on"` |

Default: `"off"` |

`Estimated controller states`

— Add estimated states output portoff (default) | on

Select this parameter to add the **est.state** output port to the block.

Block Parameter: `return_state` |

Type: string, character vector |

Values: `"off"` , `"on"` |

Default: `"off"` |

`Optimal control sequence`

— Add optimal control sequence output portoff (default) | on

Select this parameter to add the **mv.seq** output port to the block.

Block Parameter: `return_mvseq` |

Type: string, character vector |

Values: `"off"` , `"on"` |

Default: `"off"` |

`Optimal state sequence`

— Add optimal state sequence output portoff (default) | on

Select this parameter to add the **x.seq** output port to the block.

Block Parameter: `return_xseq` |

Type: string, character vector |

Values: `"off"` , `"on"` |

Default: `"off"` |

`Optimal output sequence`

— Add optimal output sequence output portoff (default) | on

Select this parameter to add the **y.seq** output port to the block.

Block Parameter:
`return_ovseq` |

Type: string, character vector |

Values: `"off"` , `"on"` |

Default: `"off"` |

`Use custom state estimation instead of using the built-in Kalman filter`

— Use custom state estimate input portoff (default) | on

Select this parameter to remove the **mo** input port and add the **x[k|k]** input port.

Block Parameter: `state_inport` |

Type: string, character vector |

Values: `"off"` , `"on"` |

Default: `"off"` |

`Lower OV limits`

— Add minimum OV constraint input portoff (default) | on

Select this parameter to add the **ymin** input port to the block.

Block Parameter: `ymin_inport` |

Type: string, character vector |

Values: `"off"` , `"on"` |

Default: `"off"` |

`Upper OV limits`

— Add maximum OV constraint input portoff (default) | on

Select this parameter to add the **ymax** input port to the block.

Block Parameter: `ymax_inport` |

Type: string, character vector |

Values: `"off"` , `"on"` |

Default: `"off"` |

`Lower MV limits`

— Add minimum MV constraint input portoff (default) | on

Select this parameter to add the **umin** input port to the block.

Block Parameter: `umin_inport` |

Type: string, character vector |

Values: `"off"` , `"on"` |

Default: `"off"` |

`Upper MV limits`

— Add maximum MV constraint input portoff (default) | on

Select this parameter to add the **umax** input port to the block.

Block Parameter: `umax_inport` |

Type: string, character vector |

Values: `"off"` , `"on"` |

Default: `"off"` |

`Custom constraints`

— Add custom constraints input portsoff (default) | on

Select this parameter to add the **E**, **F**, **G**, and **S** input ports to the block.

Block Parameter: `cc_inport` |

Type: string, character vector |

Values: `"off"` , `"on"` |

Default: `"off"` |

`OV weights`

— Add OV tuning weights input portoff (default) | on

Select this parameter to add the **y.wt** input port to the block.

Block Parameter: `ywt_inport` |

Type: string, character vector |

Values: `"off"` , `"on"` |

Default: `"off"` |

`MV weights`

— Add MV tuning weights input portoff (default) | on

Select this parameter to add the **u.wt** input port to the block.

Block Parameter: `uwt_inport` |

Type: string, character vector |

Values: `"off"` , `"on"` |

Default: `"off"` |

`MVRate weights`

— Add MV rate tuning weights input portoff (default) | on

Select this parameter to add the **du.wt** input port to the block.

Block Parameter: `duwt_inport` |

Type: string, character vector |

Values: `"off"` , `"on"` |

Default: `"off"` |

`Slack variable weight`

— Add ECR tuning weight input portoff (default) | on

Select this parameter to add the **ecr.wt** input port to the block.

Block Parameter: `rhoeps_inport` |

Type: string, character vector |

Values: `"off"` , `"on"` |

Default: `"off"` |

`Adjust prediction horizon and control horizon at run time`

— Add horizon input portsoff (default) | on

Select this parameter to add the **p** and **m** input port to the block.

Block Parameter: `pm_inport` |

Type: string, character vector |

Values: `"off"` , `"on"` |

Default: `"off"` |

`Maximum prediction horizon`

— Add horizon input ports`10`

(default) | positive integerSelect this parameter to add the **p** and **m** input port to the block.

To enable this parameter, select the **Adjust prediction horizon and control horizon at run time** parameter.

Block Parameter: `MaximumP` |

Type: string, character vector |

Default: `"10"` |

`Sample time`

— Default block sample time`1`

(default) | positive scalarDefault block sample time for performing simulation, trimming, or linearization
using the **MPC Designer** app. You must specify a sample time that is compatible
with your Simulink model design.

This parameter applies only when the **MPC Controller** parameter
is empty and you open **MPC Designer** using the **Design**
button.

Block Parameter:
`n_ts` |

Type: string, character vector |

Default:
`"1"` |

`Prediction horizon`

— Default prediction horizon`10`

(default) | positive integerDefault prediction horizon for performing simulation, trimming, or linearization
using the **MPC Designer** app. You must specify a prediction horizon that is
compatible with your Simulink model design.

This parameter applies only when the **MPC Controller** parameter
is empty and you open **MPC Designer** using the **Design**
button.

Block Parameter:
`n_p` |

Type: string, character vector |

Default:
`"10"` |

`Number of manipulated variables`

— Default number of manipulated variables`1`

(default) | positive integerDefault number of manipulated variables for performing simulation, trimming, or
linearization using the **MPC Designer** app. You must specify a value that is
compatible with your Simulink model design.

This parameter applies only when the **MPC Controller** parameter
is empty and you open **MPC Designer** using the **Design**
button.

Block Parameter:
`n_mv` |

Type: string, character vector |

Default:
`"1"` |

`Number of measured disturbances`

— Default number of measured disturbances`1`

(default) | nonnegative integerDefault number of measured disturbances for performing simulation, trimming, or
linearization using the **MPC Designer** app. You must specify a value that is
compatible with your Simulink model design.

**MPC Controller**parameter is empty and you open**MPC Designer**using the**Design**button.To use this parameter, you must select the

**Measured disturbance**parameter.

Block Parameter:
`n_md` |

Type: string, character vector |

Default:
`"1"` |

`Number of unmeasured disturbances`

— Default number of unmeasured disturbances`0`

(default) | nonnegative integerDefault number of unmeasured disturbances for performing simulation, trimming, or
linearization using the **MPC Designer** app. You must specify a value that is
compatible with your Simulink model design.

**MPC Controller** parameter
is empty and you open **MPC Designer** using the **Design**
button.

Block Parameter:
`n_ud` |

Type: string, character vector |

Default:
`"0"` |

`Number of measured outputs`

— Default number of measured outputs`1`

(default) | positive integerDefault number of measured outputs for performing simulation, trimming, or
linearization using the **MPC Designer** app. You must specify a value that is
compatible with your Simulink model design.

**MPC Controller** parameter
is empty and you open **MPC Designer** using the **Design**
button.

Block Parameter:
`n_mo` |

Type: string, character vector |

Default:
`"1"` |

`Number of unmeasured outputs`

— Default number of unmeasured outputs`0`

(default) | nonnegative integerDefault number of unmeasured outputs for performing simulation, trimming, or
linearization using the **MPC Designer** app. You must specify a value that is
compatible with your Simulink model design.

**MPC Controller** parameter
is empty and you open **MPC Designer** using the **Design**
button.

Block Parameter:
`n_uo` |

Type: string, character vector |

Default:
`"0"` |

`Inherit sample time`

— Inherit the block sample time from the controller objectoff (default) | on

Select this parameter to inherit 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).

Block Parameter: `SampleTimeInherited` |

Type: string, character vector |

Values: `"off"` , `"on"` |

Default: `"off"` |

`Use external signal to enable or disable optimization`

— Add switch input portoff (default) | on

Select this parameter to add the **switch** input port to the block.

Block Parameter: `switch_inport` |

Type: string, character vector |

Values: `"off"` , `"on"` |

Default: `"off"` |

`mv.seq`

output port signal dimensions have changed*Behavior changed in R2018b*

The signal dimensions of the `mv.seq`

output port of the MPC
Controller block have changed. Previously, this signal was a
*p*-by-*N _{mv}* matrix, where

`mv.seq`

is a
(Generate C and C++ code using Simulink® Coder™.

Generate Structured Text code using Simulink® PLC Coder™.

您点击了调用以下 MATLAB 命令的链接:

Web 浏览器不支持 MATLAB 命令。请在 MATLAB 命令窗口中直接输入该命令以运行它。

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

Select web siteYou can also select a web site from the following list:

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

- América Latina (Español)
- Canada (English)
- United States (English)

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)