str2func
Construct function handle from character vector
Syntax
Description
fh = str2func(
constructs a function
handle, str
)fh
, from a function name or text representation of an
anonymous function.
Function handles created using str2func
do not have access to
variables outside of their local workspace or to nested functions. If your function
handle contains these variables or functions, MATLAB® throws an error when you invoke the handle. Also, if you use a text
representation of an anonymous function, the resulting function handle does not have
access to private or local functions.
Examples
Input Arguments
Tips
A function handle that stores variable values does not retain its original value when you use
func2str
to convert it to a character vector, and then convert it back to a handle withstr2func
.
Extended Capabilities
Version History
Introduced before R2006a