str2func
Returns a function handle from a string.
📝Syntax
func_handle = str2func(str)
📥Input Arguments
Parameter Description
str a string
📤Output Arguments
Parameter Description
func_handle a function handle.
📄Description

function_handle = str2func(str) returns a function handle function_handle for the function named in the string str

str function name or representation of anonymous function.

💡Examples
fh = str2func('cos')
str = func2str(fh)
myFind = str2func('@(x, y) find(x > y)')
M = rand(4, 3, 5);
[R, C] = myFind(M, 0.9)
🔗See Also
func2strisfunction_handle
🕔Version History
Version Description
1.0.0 initial version
Edit this page on GitHub