MATLAB Function Reference | ![]() ![]() |
Constructs a function handle from a function name string
Syntax
fhandle = str2func('str')
Description
str2func(`str')
constructs a function handle, fhandle
, for the function named in the string, 'str'
.
You can create a function handle using either the @function
syntax or the str2func
command. You can also perform this operation on a cell array of strings. In this case, an array of function handles is returned.
Examples
To create a function handle from the function name, 'humps'
fhandle = str2func('humps') fhandle = @humps
To create an array of function handles from a cell array of function names
fh_array = str2func({'sin' 'cos' 'tan'}) fh_array = @sin @cos @tan
See Also
function_handle
, func2str
, functions
![]() | str2double | str2mat | ![]() |