how to solve matrix equation?
2 次查看(过去 30 天)
显示 更早的评论
I want to solve a equation which has vector known elements and obvisouly the answer should be vector too.
x1=sym('x1',[121 1]);
x2=sym('x2',[121 1]);
s=solve(x1+x2==n1,x1.*x2==n2,[x1,x2]);
but I think I didn't write the right code coz it's been a long time that is busy and there is no answer yet. I really need your help.
0 个评论
采纳的回答
Walter Roberson
2021-4-22
x1+x2=n1
x1*x2=n2
so
x2 = n1-x1
x1*(n1-x1) = n2
x1*n1-x1^2 = n2
x1^2 - x1*n1 + n2 = 0
and solve the quadratic to get x1 and then x2. There will be two solutions
Do this just for scalars to get the forms of the solutions. Then substitute in the vectors.
4 个评论
Walter Roberson
2021-4-24
format long g
A = rand(42,2);
Ainv = pinv(A);
Ainv * A
It isn't clear what you mean when you say that you want A * Ainv = 1 for a non-square matrix. Do you mean a matrix with all ones? Do you mean a non-square matrix in which the main diagonal is 1 and the rest is 0? What size do you expect A*Ainv to be?
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Function Creation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!