Practical 7: Symbolic Toolbox

Practical 7

Evaluating Equations

You can find the value of an equation at a point using commands subs, eval.

> Exercise: Evaluating Equations

Consider the function f(x)=\left(x^{3}+2\right) \sec x

> Define this function f in the Symbolic Toolbox, by first defining x as a symbolic variable.

> Find f(0.157)  by evaluating this function at x = 0.157 using the subs command as follows:

y = subs(f,x,0.157)

> Find f(0.123) by evaluating this function at x=0.123 using the eval command as follows:

x = 0.123

y = eval(f)

As you can see the difference in these two examples is only in the number of commands you need to use to evaluate the function at a certain x.