MATLAB: Symbolic solution to a system of equations

system equations symbolic

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

Best Answer

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