getEstimator
Obtain Kalman gains and model for estimator design
Syntax
Description
[
also returns
the system matrices used to calculate the estimator gains.L
,M
,A,Cm,Bu,Bv,Dvm
]
= getEstimator(mpcobj
)
Examples
Extract Parameters for State Estimation
The plant is a stable, discrete LTI state-space model with four states, three inputs, and three outputs. The manipulated variables are inputs 1 and 2. Input 3 is an unmeasured disturbance. Outputs 1 and 3 are measured. Output 2 is unmeasured.
Fix the number generator seed to ensure repeatable results.
rng(0)
Create a model of the plant and specify the signals for MPC.
plant = drss(4,3,3); plant.Ts = 0.25; plant = setmpcsignals(plant,MV=[1,2],UD=3,MO=[1 3],UO=2); plant.d(:,[1,2]) = 0;
The last command forces the plant to satisfy the assumption of no direct feedthrough.
Calculate the default model predictive controller for this plant.
mpcobj = mpc(plant);
-->"PredictionHorizon" is empty. Assuming default 10. -->"ControlHorizon" is empty. Assuming default 2. -->"Weights.ManipulatedVariables" is empty. Assuming default 0.00000. -->"Weights.ManipulatedVariablesRate" is empty. Assuming default 0.10000. -->"Weights.OutputVariables" is empty. Assuming default 1.00000. for output(s) y1 y3 and zero weight for output(s) y2
Obtain the parameters to be used in state estimation.
[L,M,A,Cm,Bu,Bv,Dvm] = getEstimator(mpcobj);
-->The "Model.Disturbance" property is empty: Assuming unmeasured input disturbance #3 is integrated white noise. -->Assuming output disturbance added to measured output #1 is integrated white noise. Assuming no disturbance added to measured output #3. -->"Model.Noise" is empty. Assuming white noise on each measured output.
Based on the estimator state equation, the estimator poles are given by the eigenvalues of A - L*Cm
. Calculate and display the poles.
Poles = eig(A - L*Cm)
Poles = 6×1
-0.5409
-0.0026
0.2358
0.7628
0.8595
0.9718
Confirm that the default estimator is asymptotically stable.
max(abs(Poles))
ans = 0.9718
This value is less than 1, so the estimator is asymptotically stable.
Verify that in this case, L = A*M
.
L - A*M
ans = 6×2
10-15 ×
0.0833 0.0451
0.3053 -0.0278
0.0416 -0.1665
-0.2220 -0.0104
0.0139 -0.0069
-0.0833 0.0590
Input Arguments
mpcobj
— MPC controller
MPC controller object
MPC controller, specified as an MPC controller object. Use the mpc
command to create the MPC controller.
Output Arguments
L
— Kalman gain matrix for time update
matrix
Kalman gain matrix for the time update, returned 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.
M
— Kalman gain matrix for measurement update
matrix
Kalman gain matrix for the measurement update, returned 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.
A,Cm,Bu,Bv,Dvm
— System matrices
matrices
System matrices used to calculate the estimator gains, returned as matrices of various dimensions. For definitions of these system matrices, see State Estimator Equations.
model
— System used for state-estimator design
state-space model
System used for state-estimator design, returned as a state-space
(ss
) model. The input to model
is
a vector signal comprising the following components, concatenated
in the following order:
Manipulated variables
Measured disturbance variables
1
Noise inputs to disturbance models
Noise inputs to measurement noise model
The number of noise inputs depends on the disturbance
and measurement noise models within mpcobj
.
For the category noise inputs to disturbance models, inputs to the
input disturbance model (if any) precede those entering the output
disturbance model (if any). The constant input, 1, accounts for nonequilibrium
nominal values (see MPC Prediction Models).
To make the calculation of gains L
and M
more
robust, additive white noise inputs are assumed to affect the manipulated
variables and measured disturbances (see Controller State Estimation). These
white noise inputs are not included in model
.
index
— Locations of variables within model
structure
Locations of variables within the inputs and outputs of model
.
The structure summarizes these locations with the following fields
and values.
Field Name | Value |
---|---|
ManipulatedVariables | Indices of manipulated variables within the input vector of model . |
MeasuredDisturbances | Indices of measured input disturbances within the input vector
of model . |
Offset | Index of the constant input 1 within the input vector of model . |
WhiteNoise | Indices of unmeasured disturbance inputs within the input vector
of model . |
MeasuredOutputs | Indices of measured outputs within the output vector of model . |
UmeasuredOutputs | Indices of unmeasured outputs within the output vector of model . |
Algorithms
State Estimator Equations
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. For more information, see Controller State Estimation.
At the beginning of the kth control interval, the controller state is estimated with the following steps:
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.
Revise xc(k|k–1) when uact(k–1) and uopt(k–1) are different.
Compute the innovation.
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:
Version History
Introduced in R2014b
See Also
Functions
setEstimator
|kalman
|getindist
|getoutdist
|get
|set
|sim
Objects
mpc
|mpcstate
|mpcsimopt
|mpcmoveopt
Blocks
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
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: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)