필터 지우기
필터 지우기

Find 16 variables in matrix with 16 equation in matrix

조회 수: 3 (최근 30일)
Ivan Dwi Putra
Ivan Dwi Putra 2020년 6월 10일
댓글: Ivan Dwi Putra 2020년 6월 10일
This is my code
clear; close; clc;
syms a1_head a2_head b hstar
%Parameter Massa
m1 = 8095; % massa train set 1 dalam kg
m2 = 8500; % massa train set 2 dalam kg
g = 10;
c_0_1 = 0.01176;
c_1_1 = 0.00077616;
c_2_1 = 4.48 ;
c_0_2 = 0.01176 ;
c_1_2 = 0.00077616;
c_2_2 = 4.48;
v_0 = 300;
hstar = 120;
a_1 = -1./m1.*(c_1_1 + 2.*c_2_1.*v_0);
a_2 = -1./m2.*(c_1_2 + 2.*c_2_2.*v_0);
a_1_head = 1-(a_1.*hstar);
a_2_head = 1-(a_2.*hstar);
b = 1;
% Model data
A = sym(zeros(4,4));
A(1,2) = a_1_head;
A(3,2) = (a_2_head) - 1; A(3,4) = a_2_head;
display(A);
B = sym(zeros(4,2));
B(1,1) = -b*hstar;
B(2,1) = b;
B(3,2) = -b*hstar ;
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: -Q
right_ARE = -Q;
display(right_ARE);
% Find S
[Sol_s] = solve(left_ARE == right_ARE)
% % Find S
% X = linsolve(left_ARE,right_ARE);
I try use solve and linsolve still can't get the variable and the process is very long
  댓글 수: 4
Ivan Dwi Putra
Ivan Dwi Putra 2020년 6월 10일
eft_ARE =
[ s5*(240*s1 - 2*s2 - 120*s3 + 3*s4) - s13*(360*s1 - 3*s2 - 240*s3 + 5*s4) + s9*(14400*s1 - 120*s2 - 14400*s3 + 240*s4) - s1*(28800*s1 - 240*s2 - 14400*s3 + 360*s4), (2874340168023969*s1)/70368744177664 + (2670370432474805*s3)/70368744177664 + s6*(240*s1 - 2*s2 - 120*s3 + 3*s4) - s14*(360*s1 - 3*s2 - 240*s3 + 5*s4) + s10*(14400*s1 - 120*s2 - 14400*s3 + 240*s4) - s2*(28800*s1 - 240*s2 - 14400*s3 + 360*s4), s7*(240*s1 - 2*s2 - 120*s3 + 3*s4) - s15*(360*s1 - 3*s2 - 240*s3 + 5*s4) + s11*(14400*s1 - 120*s2 - 14400*s3 + 240*s4) - s3*(28800*s1 - 240*s2 - 14400*s3 + 360*s4), (2740739176652469*s3)/70368744177664 + s8*(240*s1 - 2*s2 - 120*s3 + 3*s4) - s16*(360*s1 - 3*s2 - 240*s3 + 5*s4) + s12*(14400*s1 - 120*s2 - 14400*s3 + 240*s4) - s4*(28800*s1 - 240*s2 - 14400*s3 + 360*s4)]
[ (2874340168023969*s1)/70368744177664 + (2670370432474805*s9)/70368744177664 + s5*(240*s5 - 2*s6 - 120*s7 + 3*s8) - s13*(360*s5 - 3*s6 - 240*s7 + 5*s8) + s9*(14400*s5 - 120*s6 - 14400*s7 + 240*s8) - s1*(28800*s5 - 240*s6 - 14400*s7 + 360*s8), (2874340168023969*s2)/70368744177664 + (2874340168023969*s5)/70368744177664 + (2670370432474805*s7)/70368744177664 + (2670370432474805*s10)/70368744177664 + s6*(240*s5 - 2*s6 - 120*s7 + 3*s8) - s14*(360*s5 - 3*s6 - 240*s7 + 5*s8) + s10*(14400*s5 - 120*s6 - 14400*s7 + 240*s8) - s2*(28800*s5 - 240*s6 - 14400*s7 + 360*s8), (2874340168023969*s3)/70368744177664 + (2670370432474805*s11)/70368744177664 + s7*(240*s5 - 2*s6 - 120*s7 + 3*s8) - s15*(360*s5 - 3*s6 - 240*s7 + 5*s8) + s11*(14400*s5 - 120*s6 - 14400*s7 + 240*s8) - s3*(28800*s5 - 240*s6 - 14400*s7 + 360*s8), (2874340168023969*s4)/70368744177664 + (2740739176652469*s7)/70368744177664 + (2670370432474805*s12)/70368744177664 + s8*(240*s5 - 2*s6 - 120*s7 + 3*s8) - s16*(360*s5 - 3*s6 - 240*s7 + 5*s8) + s12*(14400*s5 - 120*s6 - 14400*s7 + 240*s8) - s4*(28800*s5 - 240*s6 - 14400*s7 + 360*s8)]
[ s5*(240*s9 - 2*s10 - 120*s11 + 3*s12) - s13*(360*s9 - 3*s10 - 240*s11 + 5*s12) + s9*(14400*s9 - 120*s10 - 14400*s11 + 240*s12) - s1*(28800*s9 - 240*s10 - 14400*s11 + 360*s12), (2874340168023969*s9)/70368744177664 + (2670370432474805*s11)/70368744177664 + s6*(240*s9 - 2*s10 - 120*s11 + 3*s12) - s14*(360*s9 - 3*s10 - 240*s11 + 5*s12) + s10*(14400*s9 - 120*s10 - 14400*s11 + 240*s12) - s2*(28800*s9 - 240*s10 - 14400*s11 + 360*s12), s7*(240*s9 - 2*s10 - 120*s11 + 3*s12) - s15*(360*s9 - 3*s10 - 240*s11 + 5*s12) + s11*(14400*s9 - 120*s10 - 14400*s11 + 240*s12) - s3*(28800*s9 - 240*s10 - 14400*s11 + 360*s12), (2740739176652469*s11)/70368744177664 + s8*(240*s9 - 2*s10 - 120*s11 + 3*s12) - s16*(360*s9 - 3*s10 - 240*s11 + 5*s12) + s12*(14400*s9 - 120*s10 - 14400*s11 + 240*s12) - s4*(28800*s9 - 240*s10 - 14400*s11 + 360*s12)]
[ (2740739176652469*s9)/70368744177664 + s5*(240*s13 - 2*s14 - 120*s15 + 3*s16) - s13*(360*s13 - 3*s14 - 240*s15 + 5*s16) + s9*(14400*s13 - 120*s14 - 14400*s15 + 240*s16) - s1*(28800*s13 - 240*s14 - 14400*s15 + 360*s16), (2740739176652469*s10)/70368744177664 + (2874340168023969*s13)/70368744177664 + (2670370432474805*s15)/70368744177664 + s6*(240*s13 - 2*s14 - 120*s15 + 3*s16) - s14*(360*s13 - 3*s14 - 240*s15 + 5*s16) + s10*(14400*s13 - 120*s14 - 14400*s15 + 240*s16) - s2*(28800*s13 - 240*s14 - 14400*s15 + 360*s16), (2740739176652469*s11)/70368744177664 + s7*(240*s13 - 2*s14 - 120*s15 + 3*s16) - s15*(360*s13 - 3*s14 - 240*s15 + 5*s16) + s11*(14400*s13 - 120*s14 - 14400*s15 + 240*s16) - s3*(28800*s13 - 240*s14 - 14400*s15 + 360*s16), (2740739176652469*s12)/70368744177664 + (2740739176652469*s15)/70368744177664 + s8*(240*s13 - 2*s14 - 120*s15 + 3*s16) - s16*(360*s13 - 3*s14 - 240*s15 + 5*s16) + s12*(14400*s13 - 120*s14 - 14400*s15 + 240*s16) - s4*(28800*s13 - 240*s14 - 14400*s15 + 360*s16)]
that is my left_ARE
in ARE
A^T.S + S.A. - S.B.R^-1.B^T.S + Q = 0
if i get the S matrix i can find K matrix and find the eigen value S matrix. I know K matrix can find with the K = lqr(A,B,Q,R), but i need S matrix to compare with K from the function, so i know the K is right with the eigenvalue from S matrix is all positive
Ivan Dwi Putra
Ivan Dwi Putra 2020년 6월 10일
in my graph that simulate the train without control LQR and in my LQRtry image with control lqr. The lqr control image still wrong, i want to the distance from x1 x3 is same after control same like x2 and x4.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by