Trying to understand dimensions of state estimates output of MPC block in Simulink

3 views (last 30 days)
I'm running an MPC in Simulink that was defined in a matlab script using the MPC Controller block and I want to inspect the state estimates of the observer which is the default input disturbance observer defined as follows:
setindist(mpcobj,'integrators');
The MPC model has 20 states:
>> size(mpcobj)
MPC controller with 4 measured output(s), 0 unmeasured output(s),
3 manipulated input(s), 0 measured disturbance(s), 3 unmeasured disturbance(s)
I wanted to check the state estimates so I selected the option to include them as an output.
However, the size of the state estimates vector is 24.
>> size(out.X_EST)
ans =
1501 24
I want to compute the estimated outputs (x3), so I need the C matrix for the observer model, which must be 3 x 24 presumably.
Whereas, the size of the plant model C matrix is 4 x 20:
>> size(mpcobj.Model.Plant.C)
ans =
4 20
What are the extra 4 states of the estimator and how do I compute the estimated outputs from these?

Accepted Answer

Bill Tubbs
Bill Tubbs on 30 Sep 2022
Edited: Bill Tubbs on 30 Sep 2022
I figured out that you can use the following to get all the parameters of the Kalman Filter including the augmented model used by the observer:
>> [L, M, A, Cm, Bu, Bv, Dvm] = getEstimator(mpcobj);
>> Cm * out.X_EST(end, :)'
ans =
6.8182
2.2083
1.2348
0.0001
Can I get this Cm matrix in simulink so I can calculate the output estimates during the simulation?
I couldn't find a way so I used a from-workspace block to get the precalculated Cm matrix and used it to copmute the output estimates like this. If anyone knows a simpler way, please let me know!

More Answers (0)

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!