This i smy matlab 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;
a2_head
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 = 1;
% 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(2,2) = svar(1);
S(2,4) = svar(2);
S(3,1) = svar(3);
S(3,2) = svar(7);
S(3,3) = svar(1);
S(4,1) = svar(4);
S(4,2) = svar(2);
S(4,3) = svar(12);
S(4,4) = svar(1);
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
[Sol_S] = solve(left_ARE == right_ARE,'Real',true)
from my code get S symmetric 4x4
S =
[ s1, s2, s3, s4]
[ s2, s1, s7, s2]
[ s3, s7, s1, s12]
[ s4, s2, s12, s1]
I use solve function like this to fidn all element S
% Find S in ARE
[Sol_S] = solve(left_ARE == right_ARE,'Real',true)
But cannot get all element S, I get error like this
Sol_S =
struct with fields:
s1: [0×1 sym]
s2: [0×1 sym]
s3: [0×1 sym]
s4: [0×1 sym]
s7: [0×1 sym]
s12: [0×1 sym]
Please help me to find all element S
Q and R in this code can change because i want find eigenvalue in S matrix is positive.

 採用された回答

Walter Roberson
Walter Roberson 2020 年 6 月 9 日

0 投票

You have 16 equations in 6 variables; there will rarely be a solution to such systems.

10 件のコメント

Ivan Dwi Putra
Ivan Dwi Putra 2020 年 6 月 9 日
is there another way to find a solution for s1,s2,s3,s4,s7 and s16 with 16 equation
Ivan Dwi Putra
Ivan Dwi Putra 2020 年 6 月 9 日
I want find the s value in ARE in LQR control. According to my understanding S in ARE LQR must be symmetric and S symmetric like that i write in code. Is my symmetric matrix 4x4 wrong? if i wrong please help me solve it. Thank you
Ivan Dwi Putra
Ivan Dwi Putra 2020 年 6 月 10 日
編集済み: Ivan Dwi Putra 2020 年 6 月 10 日
if my S like this
S =
[ s1, s2, s3, s4]
[ s2, s6, s7, s8]
[ s3, s7, s11, s12]
[ s4, s8, s12, s16]
it can use solve?because when i run same code but the S like this, very long run and no solution out
Ivan Dwi Putra
Ivan Dwi Putra 2020 年 6 月 10 日
I try to solve with S 16 variabel too
[ s1, s2, s3, s4]
[ s5, s6, s7, s8]
[ s9, s10, s11, s12]
[ s13, s14, s15, s16]
but still the program run too long and don't get the answer
Walter Roberson
Walter Roberson 2020 年 6 月 11 日
Using Maple and working iteratively, solving for s1, s2, s7, s12, s3, s4 in that order, in selected equations, then I can get down to specific expressions involving roots of a degree 6 polynomial. However, that leaves 4 equations with contradictory left and right hand sides (the rest of the equations disappear due to symmetry.) There is no overall solution.
UE := {s12*(120*s1 - 120*s3 + s7 - 2*s12) + s7*(120*s3 - s7 + s12) - s3*(14400*s3 - 120*s7 + 120*s12) - s1*(14400*s1 - 120*s12) = -1, s2*(120*s1 - s2 + s4) - s4*(120*s1 - s2 - 120*s3 + 2*s4) - s1*(14400*s1 - 120*s2 + 120*s4) - s3*(14400*s3 - 120*s4) = -1, s4*(120*s1 - 120*s3 + s7 - 2*s12) + s2*(120*s3 - s7 + s12) - s1*(14400*s3 - 120*s7 + 120*s12) - s3*(14400*s1 - 120*s12) = 0, s7*(120*s1 - s2 + s4) - s12*(120*s1 - s2 - 120*s3 + 2*s4) - s3*(14400*s1 - 120*s2 + 120*s4) - s1*(14400*s3 - 120*s4) = 0, (2740739176652469*s1)/70368744177664 + s1*(120*s1 - 120*s3 + s7 - 2*s12) + s2*(120*s3 - s7 + s12) - s4*(14400*s3 - 120*s7 + 120*s12) - s12*(14400*s1 - 120*s12) = 0, (2740739176652469*s1)/70368744177664 + s7*(s1 - s2 + 120*s4) - s12*(2*s1 - s2 + 120*s4 - 120*s12) - s3*(120*s1 - 120*s2 + 14400*s4) + s1*(120*s1 - 14400*s12) = 0, (2740739176652469*s12)/35184372088832 + s2*(s1 - s2 + 120*s4) - s1*(2*s1 - s2 + 120*s4 - 120*s12) - s4*(120*s1 - 120*s2 + 14400*s4) + s12*(120*s1 - 14400*s12) = -1, (2740739176652469*s3)/70368744177664 + s2*(s1 - s2 + 120*s4) - s4*(2*s1 - s2 + 120*s4 - 120*s12) - s1*(120*s1 - 120*s2 + 14400*s4) + s3*(120*s1 - 14400*s12) = 0, (2740739176652469*s3)/70368744177664 + s2*(120*s1 - s2 + s4) - s1*(120*s1 - s2 - 120*s3 + 2*s4) - s4*(14400*s1 - 120*s2 + 120*s4) - s12*(14400*s3 - 120*s4) = 0, (2670370432474805*s1)/70368744177664 + (2874340168023969*s3)/70368744177664 + s12*(s1 - 122*s2 + 120*s7) - s7*(s1 - 121*s2) + s1*(120*s2 - 14400*s7) + s3*(120*s1 - 14520*s2) = 0, (2670370432474805*s1)/70368744177664 + (2874340168023969*s3)/70368744177664 + s2*(120*s1 - 120*s3 + s7 - 2*s12) + s1*(120*s3 - s7 + s12) - s2*(14400*s3 - 120*s7 + 120*s12) - s7*(14400*s1 - 120*s12) = 0, (2874340168023969*s1)/70368744177664 + (2670370432474805*s3)/70368744177664 + s1*(120*s1 - s2 + s4) - s2*(120*s1 - s2 - 120*s3 + 2*s4) - s2*(14400*s1 - 120*s2 + 120*s4) - s7*(14400*s3 - 120*s4) = 0, (2874340168023969*s1)/70368744177664 + (2670370432474805*s3)/70368744177664 + s4*(s1 - 122*s2 + 120*s7) - s2*(s1 - 121*s2) + s3*(120*s2 - 14400*s7) + s1*(120*s1 - 14520*s2) = 0, (2874340168023969*s2)/35184372088832 + (2670370432474805*s7)/35184372088832 + s2*(s1 - 122*s2 + 120*s7) - s1*(s1 - 121*s2) + s7*(120*s2 - 14400*s7) + s2*(120*s1 - 14520*s2) = -1, (2874340168023969*s4)/70368744177664 + (2740739176652469*s7)/70368744177664 + (2670370432474805*s12)/70368744177664 + s1*(s1 - 122*s2 + 120*s7) - s2*(s1 - 121*s2) + s12*(120*s2 - 14400*s7) + s4*(120*s1 - 14520*s2) = 0, (2874340168023969*s4)/70368744177664 + (2740739176652469*s7)/70368744177664 + (2670370432474805*s12)/70368744177664 + s1*(s1 - s2 + 120*s4) - s2*(2*s1 - s2 + 120*s4 - 120*s12) - s2*(120*s1 - 120*s2 + 14400*s4) + s7*(120*s1 - 14400*s12) = 0}:
sol1 := {solve}(UE[1], s1):
UE2_1 := simplify(eval(UE[2 .. -1], s1 = sol1[1])):
sol2_1 := solve(UE2_1[1], s2):
UE3_1 := simplify(eval(UE2_1[2 .. -1], s2 = sol2_1)):
sol7_1 := {solve}(UE3_1[2], s7):
UE4_11 := simplify(eval([UE3_1[1], op(UE3_1[3 .. -1])], s7 = sol7_1[1])):
sol12_11 := solve(UE4_11[1], s12):
UE5_111 := eval(UE4_11[2 .. -1], s12 = sol12_11):
sol3_111 := solve(UE5_111[1], s3):
UE6_111 := eval(UE5_111[2 .. -1], s3 = sol3_111):
sol4_111 := solve(UE6_111[1], s4):
evalf([sol4_111], 16);
[-6600.222656710216, 4075.773467206679 + 86.73795020737649 I, 4075.773467206679 - 86.73795020737649 I]
UE7_1111 := eval(UE6_111[2 .. -1], s4 = sol4_111[1]):
evalf(UE7_1111, 20);
[ 6
[-1.0399606406598660253 10 + 115.0255878729092 I = -1.,
8 8
3.3643922901358482673 10 + 3.4165346168089578978 10 I = -1.,
8 6
3.3873523793910934843 10 + 2.3981331700330587530 10 I = 0.,
6 6 ]
-1.4015457557561315667 10 - 1.4023332871953215239 10 I = 0.]
Ivan Dwi Putra
Ivan Dwi Putra 2020 年 6 月 11 日
ok thank you
Ivan Dwi Putra
Ivan Dwi Putra 2020 年 6 月 11 日
what is I?
Ivan Dwi Putra
Ivan Dwi Putra 2020 年 6 月 11 日
I don't really understand, can you please explain the code?what is UE. Thank you
Walter Roberson
Walter Roberson 2020 年 6 月 11 日
I is sqrt(-1)
UE means Unique Equation. It is an arbitrary variable name. When I started the process I expected that with symmetry that some of the equations were duplicates of each other, and we only wanted the unique ones.
Important note: this is Maple code, not MATLAB code. Code in the MuPad programming language used internally by the symbolic engine would be quite similar to Maple.
The {} here are not expressing Cell Array: they are expressing Set of values.
Ivan Dwi Putra
Ivan Dwi Putra 2020 年 6 月 11 日
ok thank you

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Mathematics についてさらに検索

製品

リリース

R2020a

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by