Symbolic solution to a system of equations
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Aleem Andrew
am 1 Apr. 2020
Kommentiert: Altug Bilge
am 21 Nov. 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 Kommentare
Akzeptierte Antwort
Ameer Hamza
am 1 Apr. 2020
Bearbeitet: Ameer Hamza
am 1 Apr. 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 Kommentare
Ameer Hamza
am 11 Nov. 2020
You can use subs() function
b_val = subs(sol.b, a, 5); % substitute a=5
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Symbolic Math Toolbox 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!