Solving System of Equations Symbolically
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Michal Walko
el 10 de Mzo. de 2019
Editada: Star Strider
el 10 de Mzo. de 2019
I have a more complex system of equations than the one below, but this one has the same issue.
I want to solve for a variable in terms of other variables.
Why does this not work to solve for c?
clc
syms a b c d e
eqn1= a==b+d;
eqn2= a==e+c;
eqnarray=[eqn1 eqn2];
solve(eqnarray,c)
Clearly the answer is c=a-e -> c=b+d-e
I'm unsure as to why I'm having so much trouble with this, I've solved systems of equations before symbolically, though I've never either had free variables or overdetermined systems.
I probably could have solved my full system of equations by hand already, so I'm feeling a little slow today.
0 comentarios
Respuesta aceptada
Star Strider
el 10 de Mzo. de 2019
Subtract them:
syms a b c d e
eqn1= a==b+d;
eqn2= a==e+c;
eqnarray=[eqn1 - eqn2];
cs = solve(eqnarray,c)
producing:
cs =
b + d - e
3 comentarios
Star Strider
el 10 de Mzo. de 2019
Editada: Star Strider
el 10 de Mzo. de 2019
My approach works in this situation as well:
syms a b c d e
eqn1= b==a-d;
eqn2= a==e+c;
eqnarray=[eqn1 - eqn2];
cs = solve(eqnarray,c)
producing:
cs =
2*a - b - d - e
EDIT —
Subtracting them works by creating one algebraic equation from the pair of algebraic equations. So long as they have at least one variable in common (as they do here), you can solve for the variable of interest.
Michal Walko
el 10 de Mzo. de 2019
Editada: Michal Walko
el 10 de Mzo. de 2019
Más respuestas (0)
Ver también
Categorías
Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!