How to separate a single variable from other variables in an equation ?

6 vues (au cours des 30 derniers jours)
Ahsun Ali
Ahsun Ali le 23 Nov 2014
Commenté : Ahsun Ali le 26 Nov 2014
I have a system of linear equations written as follow : 10X-Y+2Z=6 , -X+11Y-Z=25, 2X -Y +10Z=-11. I want to separate X from its coefficient in eq. 1 , Y in eq 2 and Z in eq 3 so that eq 1 becomes X=Y/10 - Z/5 +3/5 and eq 2 as Y = X/11 + Z/11 + 25/11 and eq 3 as Z = -X/5 +Y/10 - 11/10. If there are 4 equations then the fourth variable e.g. L will be separated like the previous equations. Please tell me a way to do the above in MATLAB.
  2 commentaires
Matt J
Matt J le 23 Nov 2014
With what kind of variables? Symbolic?
Ahsun Ali
Ahsun Ali le 23 Nov 2014
Yes, symbolic variables

Connectez-vous pour commenter.

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 23 Nov 2014
Modifié(e) : Azzi Abdelmalek le 23 Nov 2014
syms X Y Z
X1=solve(10*X-Y+2*Z==6,X)
Y1=solve(-X+11*Y-Z==25,Y)
Z1=solve(2*X -Y +10*Z==-11,Z)
  2 commentaires
Ahsun Ali
Ahsun Ali le 23 Nov 2014
Thank you very much ! works great.
Ahsun Ali
Ahsun Ali le 26 Nov 2014
What if these equations were in a matrix or an array and the symbolic characters in another matrix then how will the above be done ? e.g equations= [10*X-Y+2*z=6, -X+11*Y-Z=25, 2*X-Y+10*Z=-11] and variables=[X, Y, Z] then how would you do X1=solve(equations(1),variables(1)) and Y1=solve(equations(2),variables(2)) and so on ? i tried doing this but matlab gave an error '10*X-Y+2*z' is not a valid equation for the first equation.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by