Main Content

Controller State Estimation

Controller State Variables

As the controller operates, it uses its current state, xc, as the basis for predictions. By definition, the state vector is the following:



  • xc is the controller state, comprising nxp + nxid + nxod + nxn state variables.

  • xp is the plant model state vector, of length nxp.

  • xid is the input disturbance model state vector, of length nxid.

  • xod is the output disturbance model state vector, of length nxod.

  • xn is the measurement noise model state vector, of length nxn.

Thus, the variables comprising xc represent the models appearing in the following diagram of the MPC system.

Some of the state vectors may be empty. If not, they appear in the sequence defined within each model.

By default, the controller updates its state automatically using the latest plant measurements. See State Estimation for details. Alternatively, the custom state estimation feature allows you to update the controller state using an external procedure, and then supply these values to the controller. See Custom State Estimation for details.

State Observer

Combination of the models shown in the diagram yields the state observer:


MPC controller uses the state observer in the following ways:

  • To estimate values of unmeasured states needed as the basis for predictions (see State Estimation).

  • To predict how the controller’s proposed manipulated variable (MV) adjustments will affect future plant output values (see Output Variable Prediction).

The observer’s input signals are the dimensionless plant manipulated and measured disturbance inputs, and the white noise inputs to the disturbance and noise models:


The observer’s outputs are the ny dimensionless plant outputs.

In terms of the parameters defining the four models shown in the diagram, the observer’s parameters are:


Here, the plant and output disturbance models are resequenced so that the measured outputs precede the unmeasured outputs.

State Estimation

In general, the controller states are unmeasured and must be estimated. By default, the controller uses a steady-state Kalman filter that derives from the state observer.

At the beginning of the kth control interval, the controller state is estimated with the following steps:

  1. Obtain the following data:

    • xc(k|k–1) — Controller state estimate from previous control interval, k–1

    • uact(k–1) — Manipulated variable (MV) actually used in the plant from k–1 to k (assumed constant)

    • uopt(k–1) — Optimal MV recommended by MPC and assumed to be used in the plant from k–1 to k

    • v(k) — Current measured disturbances

    • ym(k) — Current measured plant outputs

    • Bu, Bv — Columns of observer parameter B corresponding to u(k) and v(k) inputs

    • Cm — Rows of observer parameter C corresponding to measured plant outputs

    • Dmv — Rows and columns of observer parameter D corresponding to measured plant outputs and measured disturbance inputs

    • L, M — Constant Kalman gain matrices

    Plant input and output signals are scaled to be dimensionless prior to use in calculations.

  2. Revise xc(k|k–1) when uact(k–1) and uopt(k–1) are different.


  3. Compute the innovation.


  4. Update the controller state estimate to account for the latest measurements.


    Then, the software uses the current state estimate xc(k|k) to solve the quadratic program at interval k. The solution is uopt(k), the MPC-recommended manipulated-variable value to be used between control intervals k and k+1.

    Finally, the software prepares for the next control interval assuming that the unknown inputs, wid(k), wod(k), and wn(k) assume their mean value (zero) between times k and k+1. The software predicts the impact of the known inputs and the innovation as follows:


Built-in Steady-State Kalman Gains Calculation

Model Predictive Control Toolbox™ software uses the kalman command to calculate Kalman estimator gains L and M. The following assumptions apply:

  • State observer parameters A, B, C, D are time-invariant.

  • Controller states, xc, are detectable. (If not, or if the observer is numerically close to undetectability, the Kalman gain calculation fails, generating an error message.)

  • Stochastic inputs wid(k), wod(k), and wn(k) are independent white noise, each with zero mean and identity covariance.

  • Additional white noise wu(k) and wv(k) with the same characteristics adds to the dimensionless u(k) and v(k) inputs respectively. This improves estimator performance in certain cases, such as when the plant model is open-loop unstable.

Without loss of generality, set the u(k) and v(k) inputs to zero. The effect of the stochastic inputs on the controller states and measured plant outputs is:




Inputs to the kalman command are the state observer parameters A, Cm, and the following covariance matrices:


Here, E{...} denotes the expectation.

Output Variable Prediction

Model Predictive Control requires prediction of noise-free future plant outputs used in optimization. This is a key application of the state observer (see State Observer).

In control interval k, the required data are as follows:

  • p — Prediction horizon (number of control intervals, which is greater than or equal to 1)

  • xc(k|k) — Controller state estimates (see State Estimation)

  • v(k) — Current measured disturbance inputs (MDs)

  • v(k+i|k) — Projected future MDs, where i=1:p–1. If you are not using MD previewing, then v(k+i|k) = v(k).

  • A, Bu, Bv, C, Dv — State observer constants, where Bu, Bv, and Dv denote columns of the B and D matrices corresponding to inputs u and v. Du is a zero matrix because of no direct feedthrough

Predictions assume that unknown white noise inputs are zero (their expectation). Also, the predicted plant outputs are to be noise-free. Thus, all terms involving the measurement noise states disappear from the state observer equations. This is equivalent to zeroing the last nxn elements of xc(k|k).

Given the above data and simplifications, for the first step the state observer predicts:


Continuing for successive steps, i = 2:p, the state observer predicts:


At any step, i = 1:p, the predicted noise-free plant outputs are:


All of these equations employ dimensionless plant input and output variables. See Specify Scale Factors. The equations also assume zero offsets. Inclusion of nonzero offsets is straightforward.

For faster computations, the MPC controller uses an alternative form of the above equations in which constant terms are computed and stored during controller initialization. See QP Matrices.

See Also




Related Examples

More About