Symbolic solution to a system of equations
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Aleem Andrew
el 1 de Abr. de 2020
Comentada: Altug Bilge
el 21 de Nov. de 2020
Can Matlab solve a system of equations like a+b=c, b=2c symbolically for b and c? The output should be c=-a, b=-2a
0 comentarios
Respuesta aceptada
Ameer Hamza
el 1 de Abr. de 2020
Editada: Ameer Hamza
el 1 de Abr. de 2020
In MATLAB you solve it like this using symbolic variables and solve function()
syms a b c
eq1 = a+b==c;
eq2 = b==2*c;
sol = solve([eq1 eq2])
Result:
>> sol.b
ans =
-2*a
>> sol.c
ans =
-a
5 comentarios
Ameer Hamza
el 11 de Nov. de 2020
You can use subs() function
b_val = subs(sol.b, a, 5); % substitute a=5
Más respuestas (1)
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!