Reputation: 3374
I have a matrix, let's say 5x5 looking like this:
0 0 0 1 0
0 0 0 4/5 1/5
3/5 1/5 1/5 0 0
1/5 2/5 1/5 1/5 0
1/10 1/10 2/5 1/5 1/5
I need it to solve it like a system of linear equations looking like this (I can transpose it myself, but then multiplying it with the symbolic variables gets me into troubles):
0 * a + 0 * b + 3/5 * c + 1/5 * d + 1/10 + e = a
0 * a + 0 * b + 1/5 * c + 2/5 * d + 1/10 + e = b
0 * a + 0 * b + 1/5 * c + 1/5 * d + 2/5 + e = c
1 * a + 4/5 * b + 0 * c + 1/5 * d + 1/5 + e = d
0 * a + 1/5 * b + 0 * c + 0 * d + 1/5 + e = e
a + b + c + d + e = 1
I can easily solve this in wxMaxima, but I have to manually write all the values there, which is increasingly tedious with bigger matrices.
Is there a way to get the results after some steps using matlab operator \
for solving system of linear equations?
Upvotes: 2
Views: 607
Reputation: 35099
And a symbolic solution:
M=sym(A);
v=sym('[a;b;c;d;e]');
sol=solve(M*v==v,sum(v)==1);
returns solutions in the form sol.a
, sol.b
, ...
Upvotes: 1
Reputation: 3106
You can solve the equation set no?
>>[A-eye(5);ones(1,5)]\[0,0,0,0,0,1]'
ans =
0.1729
0.2061
0.1345
0.4350
0.0515
>> sum(ans)
ans =
1.0000
Upvotes: 3