Solve linear equation in matrix form
Afficher commentaires plus anciens
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?
Réponses (1)
Why don't you use
pi0 = null((A0+R*B).');
if ~isempty(pi0)
pi0 = pi0.'/(pi0.'*inv(I-R)*e)
end
9 commentaires
DoinK
le 6 Mai 2023
DoinK
le 6 Mai 2023
DoinK
le 7 Mai 2023
DoinK
le 9 Mai 2023
Torsten
le 9 Mai 2023
For that pi^0*M = 0 for a matrix M and a nonzreo vector pi^0, M does not need to be zero. pi^0 has to lie in the nullspace of M.'.
DoinK
le 12 Mai 2023
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.
Catégories
En savoir plus sur Linear Algebra dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!