Main Content


MPC controller state


The mpcstate object represents the state of an implicit or explicit MPC controller. Use an mpcstate object to initialize the controller object before simulation.

The controller state includes the:

  • States of the plant, disturbance, and noise models of the controller.

  • Manipulated variables used in the previous control interval.

  • State covariance matrix for the controller.

mpcstate objects are updated during simulation using the internal state observer based on the extended prediction model. The overall state is updated from the measured output ym(k) by a linear state observer. For mode information, see Controller State Estimation.




x = mpcstate(mpcobj) creates a controller state object for the implicit or explicit MPC controller mpcobj, setting the state object properties to their default values.

x = mpcstate(mpcobj,plant,disturbance,noise,lastMove,covariance) sets the properties of the state object to specified nondefault values. To use default values for a given property, set the corresponding input argument to [].

Input Arguments

expand all

MPC controller object, specified as either an mpc or explicitMPC object.


expand all

Plant model state estimates, specified as a vector. The plant state estimate values are in engineering units and are absolute; that is, they include state offsets. By default, the Plant property is equal to the Model.Nominal.X property of the controller used to create the mpcstate object.

If the controller plant model includes delays, the Plant property includes states that model the delays. Therefore the number of elements in Plant is greater than the order of the nondelayed controller plant model.

Disturbance model state estimates, specified as a vector. The disturbance state estimates include the states of the input disturbance model followed by the states of the output disturbance model. By default, the Disturbance property is a zero vector if the controller has disturbance model states and empty otherwise.

To view the input and output disturbance models of your controller, use the getindist and getoutdist functions, respectively.

Output measurement noise model state estimates, specified as a vector. By default, the Noise property is a zero vector if the controller has noise model states and empty otherwise.

Optimal manipulated variable control move from previous control interval, specified as a vector with length equal to the number of manipulated variables. By default, the LastMove property is equal to the nominal values of the manipulated variables.

During simulation, the mpcmove function automatically sets the value of LastMove.

When the actual control signals sent to the plant in the previous control interval do not match the calculated optimal value, do not use LastMove to specify the actual control signals. Instead, do so using mpcmoveopt.

Covariance matrix for controller state estimates, specified as an Ns-by-Ns symmetric matrix, where Ns is the sum of the number states contained in the Plant, Disturbance, and Noise fields. T

If the controller is employing default state estimation the default covariance matrix is the steady-state covariance computed according to the assumptions in Controller State Estimation. For more information, see the description of the P output argument of the kalmd function.

If the controller uses custom state estimation, the Covariance property is empty and not used.

During simulation, do not modify Covariance. The mpcmove function automatically sets the value of Covariance at each control interval.

Object Functions

mpcmoveCompute optimal control action and update controller states
mpcmoveAdaptiveCompute optimal control with prediction model updating
mpcmoveMultipleCompute gain-scheduling MPC control action at a single time instant
mpcmoveExplicitCompute optimal control using explicit MPC


collapse all

Create a model predictive controller for a single-input-single-output (SISO) plant. For this example, the plant includes an input delay of 0.4 time units, and the control interval to 0.2 time units.

H = tf(1,[10 1],'InputDelay',0.4);
MPCobj = mpc(H,0.2);
-->The "PredictionHorizon" property is empty. Assuming default 10.
-->The "ControlHorizon" property is empty. Assuming default 2.
-->The "Weights.ManipulatedVariables" property is empty. Assuming default 0.00000.
-->The "Weights.ManipulatedVariablesRate" property is empty. Assuming default 0.10000.
-->The "Weights.OutputVariables" property is empty. Assuming default 1.00000.

Create the corresponding controller state object in which all states are at their default values.

xMPC = mpcstate(MPCobj)
-->Converting the "Model.Plant" property to state-space.
-->Converting model to discrete time.
-->Converting delays to states.
-->Assuming output disturbance added to measured output channel #1 is integrated white noise.
-->The "Model.Noise" property is empty. Assuming white noise on each measured output.
MPCSTATE object with fields
          Plant: [0 0 0]
    Disturbance: 0
          Noise: [1x0 double]
       LastMove: 0
     Covariance: [4x4 double]

The plant model, H, is a first-order, continuous-time transfer function. The Plant property of the mpcstate object contains two additional states to model the two intervals of delay. By default, the controller contains a first-order output disturbance model (Disturbance property is a scalar) and a static gain noise model (Noise property is empty).

You can access the properties of the controller state object using dot notation. For example, view the default covariance matrix.

ans = 4×4

    0.0624    0.0000    0.0000   -0.0224
    0.0000    1.0000    0.0000   -0.0000
    0.0000    0.0000    1.0000    0.0000
   -0.0224   -0.0000    0.0000    0.2301

Version History

Introduced before R2006a