Suppose you have a string like
rhs = 'x*cos(x)/(t+1)';
and that you want to create a function handle… would you do
fHandle = str2func(['@(t,x)',rhs])
or
fHandle = eval(['@(t,x)',rhs]);
or
?
Can you explain why?
evalfunction handlestr2func
rhs = 'x*cos(x)/(t+1)';
fHandle = str2func(['@(t,x)',rhs])
fHandle = eval(['@(t,x)',rhs]);
?
Best Answer