[英]Solve special system of linear equations in Matlab (GNU Octave)
I have a matrix, let's say 5x5 looking like this: 我有一个矩阵,让我们说5x5看起来像这样:
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. 我可以在wxMaxima中轻松解决这个问题,但是我必须手动编写那里的所有值,这对于更大的矩阵来说越来越乏味。
Is there a way to get the results after some steps using matlab operator \\
for solving system of linear equations? 有没有办法在使用matlab运算符
\\
某些步骤后得到结果来求解线性方程组?
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
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
, ... 返回
sol.a
, sol.b
,...形式的解决方案
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.