Symbolic Math Toolbox | ![]() ![]() |
Creating Symbolic Math Functions
There are two ways to create functions:
Using Symbolic Expressions
generates the symbolic expressions r
, t
, and f
. You can use diff
, int
, subs
, and other Symbolic Math Toolbox functions to manipulate such expressions.
Creating an M-File
M-files permit a more general use of functions. Suppose, for example, you want to create the sinc
function sin(x)/x
. To do this, create an M-file in the @sym
directory:
function z = sinc(x) %SINC The symbolic sinc function % sin(x)/x. This function % accepts a sym as the input argument. if isequal(x,sym(0)) z = 1; else z = sin(x)/x; end
You can extend such examples to functions of several variables. See the MATLAB topic Programming and Data Types for a more detailed discussion on object-oriented programming.
![]() | Symbolic and Numeric Conversions | Using the Symbolic Math Toolbox | ![]() |