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!