@sym
: eval (f) ¶Symbolic expression to double, taking values from workspace.
For expressions without symbols, eval
does the same thing
as double
:
f = 2*sin(sym(3)) ⇒ f = (sym) 2⋅sin(3) eval(f) ⇒ ans = 0.2822 double(f) ⇒ ans = 0.2822
For an expression containing symbols, eval
looks in the
workspace for variables whose names match the symbols. It then
evaluates the expression using the values from those variables.
For example:
syms x y f = x*sin(y) ⇒ f = (sym) x⋅sin(y)
x = 2.1 ⇒ x = 2.1000 y = 2.9 ⇒ y = 2.9000
f ⇒ f = (sym) x⋅sin(y) eval(f) ⇒ ans = 0.5024
See also: @sym/subs.
Package: symbolic