Main Content

setEstimator

Modify a model predictive controller’s state estimator

Description

setEstimator(mpcobj,L,M) sets the gain matrices used for estimation of the states of an MPC controller. For more information, see State Estimator Equations.

example

setEstimator(mpcobj,'default') restores the gain matrices L and M to their default values. The default values are the optimal static gains calculated using kalmd for the plant, disturbance, and measurement noise models specified in mpcobj.

setEstimator(mpcobj,'custom') specifies that controller state estimation will be performed by a user-supplied procedure. This option suppresses calculation of L and M. When the controller is operating in this way, the procedure must supply the state estimate x[n|n] to the controller at the beginning of each control interval.

Examples

collapse all

Design an estimator using pole placement, assuming the linear system AM=L is solvable.

Create a plant model.

G = tf({1,1,1},{[1 .5 1],[1 1],[.7 .5 1]});

To improve the clarity of this example, call mpcverbosity to suppress messages related to working with an MPC controller.

old_status = mpcverbosity('off');

Create a model predictive controller for the plant. Specify the controller sample time as 0.2 seconds.

mpcobj = mpc(G, 0.2);

Obtain the default state estimator gain.

[~,M,A1,Cm1] = getEstimator(mpcobj);

Calculate the default observer poles.

e = eig(A1-A1*M*Cm1);
abs(e)
ans = 6×1

    0.9402
    0.9402
    0.8816
    0.8816
    0.7430
    0.9020

Specify faster observer poles.

new_poles = [.8 .75 .7 .85 .6 .81];

Compute a state-gain matrix that places the observer poles at new_poles.

L = place(A1',Cm1',new_poles)';

place returns the controller-gain matrix, whereas you want to compute the observer-gain matrix. Using the principle of duality, which relates controllability to observability, you specify the transpose of A1 and Cm1 as the inputs to place. This function call yields the observer gain transpose.

Obtain the estimator gain from the state-gain matrix.

M = A1\L;

Specify M as the estimator for mpcobj.

setEstimator(mpcobj,L,M)

The pair, (A1,Cm1), describing the overall state-space realization of the combination of plant and disturbance models must be observable for the state estimation design to succeed. Observability is checked in Model Predictive Control Toolbox™ software at two levels: (1) observability of the plant model is checked at construction of the MPC object, provided that the model of the plant is given in state-space form; (2) observability of the overall extended model is checked at initialization of the MPC object, after all models have been converted to discrete-time, delay-free, state-space form and combined together.

Restore mpcverbosity.

mpcverbosity(old_status);

Input Arguments

collapse all

MPC controller, specified as an MPC controller object. Use the mpc command to create the MPC controller.

Kalman gain matrix for the time update, specified as a matrix. The dimensions of L are nx-by-nym, where nx is the total number of controller states, and nym is the number of measured outputs.

If L is empty, it defaults to L = A*M, where A is the state-transition matrix.

Kalman gain matrix for the measurement update, specified as a matrix. The dimensions of L are nx-by-nym, where nx is the total number of controller states, and nym is the number of measured outputs.

If M is omitted or empty, it defaults to a zero matrix, and the state estimator becomes a Luenberger observer.

Algorithms

collapse all

Version History

Introduced in R2014b