f(inputs) = formula
creates the symbolic function f. For example, f(x,y) =
x + y. The symbolic variables in inputs are the
input arguments. The symbolic expression formula is the body of
the function f.
f = symfun(formula,inputs)
is the formal way to create a symbolic function.
Define the symbolic function x + y. First,
create the function by using syms. Then define the
function.
syms f(x,y)
f(x,y) = x + y
f(x, y) =
x + y
Find the value of f at x = 1 and
y = 2.
f(1,2)
ans =
3
Define the function again by using the formal way.
syms x y
f = symfun(x+y,[x y])
f(x, y) =
x + y
Return Body and Arguments of Symbolic Function
Return the body of a symbolic function by using
formula. You can use the body for operations such as
indexing into the function. Return the arguments of a symbolic function by using
argnames.
Index into the symbolic function [x^2, y^4]. Since a
symbolic function is a scalar, you cannot directly index into the function.
Instead, index into the body of the function.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.