Symbolic functions represent math functions. Use symbolic functions for differentiation,
integration, solving ODEs, and other math operations. Create symbolic functions by using
Symbolic functions must be functions of symbolic variables. The Symbolic Math Toolbox™ currently does not support composite symbolic functions, or symbolic functions that are functions of another symbolic functions.
Create a symbolic function
f with variables
y by using
Assign a mathematical expression to
f(x,y) = x^2*y
f(x, y) = x^2*y
Find the value of
ans = 18
Symbolic functions accept array inputs. Calculate
f for multiple values
xVal = 1:5; yVal = 3:7; f(xVal,yVal)
ans = [ 3, 16, 45, 96, 175]
You can differentiate symbolic functions, integrate or simplify them, substitute their
arguments with values, and perform other mathematical operations. For example, find the
f(x,y) with respect to
x. The result
dfx is also a symbolic function.
dfx = diff(f,x)
dfx(x,y) = 2*x*y
x = y + 1.
ans = 2*y*(y + 1)
If you are creating a constant function, such as
f(x,y) = 1, you must
f(x,y). If you do not create
f(x,y) = 1 throws an error.