Solve linear equation in matrix form
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
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 个评论
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 Exchange 中查找有关 Operating on Diagonal Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!