Find S value in Algebra Ricatti Equation LQR

6 views (last 30 days)
Ivan Dwi Putra on 13 May 2020
Answered: Ivan Dwi Putra on 15 May 2020
I have code like that
In that code i want find S matriks Value with left_ARE = Right_are it can?
clear; close; clc;
syms a1 a2 b h
% Model data
A = sym(zeros(4,4));
A(1,2) = a1;
A(3,2) = a2-1; A(3,4) = a2;
display(A);
B = sym(zeros(4,2));
B(1,1) = -b*h;
B(2,1) = b;
B(3,2) = -b*h;
B(4,1) = -b; B(4,2) = b;
display(B);
% Q and R matrices for ARE
Q = sym(eye(4)); display(Q);
R = sym(zeros(2,2)); R(1,:) = [1 1]; R(2,:) = [1 2]; display(R);
% Matrix S to find
svar = sym('s',[1 16]);
S = [svar(1:4); svar(5:8); svar(9:12); svar(13:16)];
S(2,1) = svar(2);
S(3,1) = svar(3);
S(3,2) = svar(7);
S(4,1) = svar(4);
S(4,2) = svar(8);
S(4,3) = svar(12);
display(S);
% LHS of ARE: A'*S + S*A' - S*B*Rinv*B'*S
left_ARE = transpose(A)*S + S*A - S*B*inv(R)*transpose(B)*S;
display(left_ARE);
% RHS of ARE: A'*S + S*A' - S*B*Rinv*B'*S
right_ARE = -Q;
display(right_ARE);
% Find S in ARE
S = left_ARE == right_ARE;
display(S);

Ivan Dwi Putra on 15 May 2020
I want find s1 until s16 value in S matrix