Solve linear equation in matrix form
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I need to find pi^(0) from this linear equation
pi^(0) is a row vector, e is column vector of 1
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1376309/image.jpeg)
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1376314/image.png)
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?
0 comentarios
Respuestas (1)
Torsten
el 6 de Mayo de 2023
Editada: Torsten
el 6 de Mayo de 2023
Why don't you use
pi0 = null((A0+R*B).');
if ~isempty(pi0)
pi0 = pi0.'/(pi0.'*inv(I-R)*e)
end
9 comentarios
Torsten
el 12 de Mayo de 2023
Editada: Torsten
el 12 de Mayo de 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.
Ver también
Categorías
Más información sobre Operating on Diagonal Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!