how to solve matrix equation?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Walter Roberson
il 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 Commenti
Walter Roberson
il 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?
Più risposte (1)
Vedere anche
Categorie
Scopri di più su Function Creation in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!