MATLAB: What would you do

evalfunction handlestr2func

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?

Best Answer

I'd tend to choose str2func, merely because it makes it more obvious what I'm anticipating as an output.
Related Question