What I'm trying to do
- I'm trying to create a LQG controller to control a given system by combining a Linear Quadratic Regulator (LQR) and a Kalman Filter.
Where I'm stuck
I have found both separately, but am unsure how I combine them in MATLAB. This is the system and LQR solution:
I am able to create both the Kalman Filter and the LQR seperately, but I can't figure out how to combine the LQR to take the Kalman Filter State Estimate as its input.
Akal = Afull;
Bkal = [B1, B2];
Ckal = Cfull;
Dkal = [0 0];
sys_kal = ss(Akal,Bkal,Ckal,Dkal);
[KEST,L,P] = kalman(sys_kal,E_d, E_n, 0)
[K,S,e] = lqr(Afull,B1,Q,r);
When I use the kalman function, here is what size(KEST)
gives me:
State-space model with 11 outputs, 2 inputs, and 10 states.
I want my U
to use the estimate given by the new SS system KEST
. KEST
provides an estimate for the output (y
, dimension 1), and an estimate for all 10 states (X
, dimension 10). I can write/draw out the closed loop control path that I am looking to create using the LQR and Kalman functions, but I am stuck at this point because I don't know how to implement it via MATLAB. I am unsure of the syntax as well.
I have searched for MATLAB examples but haven't found any that show me how to combine what I have found. I know that KEST
is a state space model but I don't know how to use it or select a single output.
What I'm hoping to get help with
If I use
bode(KEST)
, it gives me a BODE plot of all 11 outputs. I am not sure how to select just a single output ofKEST
.I would like to have
U = -K*X_est
, but currently I just know the value ofK
. I don't know how to obtain anX_est
from myKEST
state space system.