how to solve matrix equation?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Nara Lee
am 18 Apr. 2021
Beantwortet: Nara Lee
am 24 Apr. 2021
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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 22 Apr. 2021
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 Kommentare
Walter Roberson
am 24 Apr. 2021
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?
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Function Creation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!