doc str2func
but unless you know what you are doing (or you are just playing to see how that works), approaches that rely on converting a string to a function are often flawed (*).
Anyhow, note that you could allow users to pass a function handle instead of a string or char variable:
function plot_on_01( func )
x = 0 : 0.1 : 1 ;
plot( x, func(x) ) ;
grid on ;
end
can be called as follows:
plot_on_01( @sin )
plot_on_01( @cos )
plot_on_01( @sqrt )
plot_on_01( @exp )
plot_on_01( @(x)log10(1+x) )
Note (*): I am using STR2FUNC for example when I am building test suites for large projects, but otherwise it is very rare.