Practical 7: Symbolic Toolbox

Practical 7

Example

 

> Exercise: Another Example of Solving Symbolic Equation

> Solve the general quadratic equation ax^{2}+bx+c=0 for any x by making the three coefficients a, b, c and x symbolic variables.

syms a b c x

> Instead of creating a new variable f for function, use the following command to solve directly:

soln = solve(a*x^2+b*x+c)

 

The above command doesn’t specify the variable to solve for. If it is not specified, the solve command will:

1) Solve for x by default or

2) Solve for the last alphabetical variable if there is no variable called x or

3) Solve for the only symbolic variable if there is only one.

> Exercise

> Solve the equation again, replacing a with u, b with v, c with w and x with s.

syms u v w s

...

> What is the answer this time?