A function handle is a pointer to another function and is defined with the syntax
f = @sin;
creates a function handle called
f that refers to the
Function handles are used to call other functions indirectly, or to pass
a function as an argument to another function like
fsolve. For example:
f = @sin; quad (f, 0, pi) ⇒ 2
You may use
feval to call a function using function handle, or
simply write the name of the function handle followed by an argument
list. If there are no arguments, you must use an empty argument list
‘()’. For example:
f = @sin; feval (f, pi/4) ⇒ 0.70711 f (pi/4) ⇒ 0.70711
Return true if x is a function handle.
See also: isa, typeinfo, class, functions.
Return a structure containing information about the function handle fcn_handle.
The structure s always contains these three fields:
The function name. For an anonymous function (no name) this will be the actual function definition.
Type of the function.
The function is anonymous.
The function is private.
The function overloads an existing function.
The function is a built-in or m-file function.
The function is a subfunction within an m-file.
The m-file that will be called to perform the function. This field is empty for anonymous and built-in functions.
In addition, some function types may return more information in additional fields.
functions is provided for debugging purposes only.
It’s behavior may change in the future and programs should not depend on a
Return a string containing the name of the function referenced by the function handle fcn_handle.
See also: str2func, functions.
Return a function handle constructed from the string fcn_name.
If the optional
"global" argument is passed, locally visible
functions are ignored in the lookup.
str2func does not currently accept strings which define
anonymous functions (those which begin with ‘@’).
eval (str) as a replacement.
See also: func2str, inline.