Solving equations in Matlab

PHOTO EMBED

Sat Mar 20 2021 07:27:54 GMT+0000 (Coordinated Universal Time)

Saved by @FlorianC #matlab

# declare symbolic variables
syms a b c x
y = a*x^2 + b*x + c

soln = solve(y == 0, x);
# solve for specific values
ysoln = subs(soln, [a,b,c],[3,2,-6])
ysoln = simplify(ysoln);

# get decimal number with 9 digits
vpa(ysoln, 9)
content_copyCOPY