フィルターのクリア

Solve linear equation in matrix form

3 ビュー (過去 30 日間)
DoinK
DoinK 2023 年 5 月 6 日
編集済み: Torsten 2023 年 5 月 12 日
I need to find pi^(0) from this linear equation
pi^(0) is a row vector, e is column vector of 1
where A_0, R, B, A, and C are square matrix.
Matrix A_0, B, A, and C are given.
R can be found by using successive substitutions method
After i found R, i use this code to find pi^(0) (q is the same as pi^(0))
q=sym('q',[1 mm]) %row vector
I=eye(mm);
e=ones(mm,1); %column vector of 1
a=q*(inv(I-R))*e %size 1 1
aa=a-1
j=solve(aa,sym('q1')) %j is the same as q1=
w=q*(A_0+R*B) %size 1 row mm column
k=subs(w,sym('q1'),j) %subs q1 with j
[C,S]=equationsToMatrix(k,q)
rank(S)
rank(C) %if rank(C)=rank([C,S]) the system can be solved
rank([C,S])
ji=C\S %ji is pi^(0) which i need to find and must fulfill all value less than 1 and non negative.
But, after i run, rank(C)/=rank([C,S]) so the system can't be solved
Is there any code that is wrong? or there is code that more simple than this code?

回答 (1 件)

Torsten
Torsten 2023 年 5 月 6 日
編集済み: Torsten 2023 年 5 月 6 日
Why don't you use
pi0 = null((A0+R*B).');
if ~isempty(pi0)
pi0 = pi0.'/(pi0.'*inv(I-R)*e)
end
  9 件のコメント
DoinK
DoinK 2023 年 5 月 12 日
Thankyou for your explanation Sir, it really help me.
One more question, from my matrix A_0, B, A, C, and R
If I compute manual
[a b c] * (A_0+RB)=[0 0 0] , I get 3 linear equation name 1, 2, and 3.
[a b c]*(inv(I-R))*[1 1 1].'=1 , I get 1 linear equation name 4.
From my calculation, If I use eq. 1 2 3 and 4, no solution exist.
If I use eq. 1 2 and 3, a=0, b=0, c=0.
If I use eq. 4 and 2 more equation between (1,2,or 3) , there are solutions for a, b, c but the value is not fix. Have a litte different if I use another equation to compare.
Example if I use eq. 4 1 2 compare to eq. 4 2 3, there is a difference in the 6th number after comma.
Torsten
Torsten 2023 年 5 月 12 日
編集済み: Torsten 2023 年 5 月 12 日
I don't understand why you experiment above with solutions to 3 equations out of the 4.
For that your problem has a solution, there must exist a vector different from the null vector that satisfies pi^0*(A_0+R*B) = 0 or (A_0+R*B).'*pi^0.' = 0. If such vector(s) exist, you'll get a basis of the vector space spanned by these vectors by the command null((A_0+R*B).'). If the result of this command is empty, your problem has no solution.
Equivalently you can check whether rank((A_0+R*B).') < 3. If this is the case, you'll also be able to solve your problem.

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

カテゴリ

Help Center および File ExchangeOperating on Diagonal Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by