matlabFunction
Convert symbolic expression to function handle or file
Description
specifies options using one or more name-value arguments in addition to any of the
input argument combinations in the previous syntaxes.ht
= matlabFunction(___,Name,Value
)
For example, you can specify the File
name-value argument to
write the generated MATLAB function to a file. You can also specify the Vars
name-value argument to generate a MATLAB function with input arguments that are a
combination of scalar and vector variables.
Examples
Input Arguments
Output Arguments
Limitations
Some symbolic functions that have no corresponding MATLAB functions operating on the
double
data type, such assimplify
andsolve
, are kept as symbolic functions in the converted MATLAB function handle or file. The converted file that consists of these functions cannot be deployed using MATLAB Coder™ or MATLAB Compiler™. You need to create your own functions with thedouble
data type to replace these symbolic functions. If you are interested in a symbolic function that cannot be deployed, please contact MathWorks Technical Support.
Tips
When you use the
File
argument, userehash
to make the generated function available immediately.rehash
updates the MATLAB list of known files for directories on the search path.If the
File
option is empty, then an anonymous function is returned.Use
matlabFunction
to convert one or more symbolic expressions to a MATLAB function and write the resulting function to an M-file. You can then use the generated M-file to create standalone applications and web apps using MATLAB Compiler. For example, see Deploy Generated MATLAB Functions from Symbolic Expressions with MATLAB Compiler.Use
matlabFunction
to convert one or more symbolic expressions to a MATLAB function and write the resulting function to an M-file. You can then use the generated M-file to create C or C++ code using MATLAB Coder app. For example, see Generate C Code from Symbolic Expressions Using the MATLAB Coder App.To generate a MATLAB function with input arguments that are a combination of scalar and vector variables, specify the
Vars
name-value argument as a cell array. For examples, see Specify Input Arguments for Generated Function and Generate Function with Vector Input Arguments.
Version History
Introduced in R2008b
See Also
ccode
| daeFunction
| fortran
| rehash
| matlabFunctionBlock
| odeFunction
| simscapeEquation
| subs
| sym2poly