What would you do?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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?
0 comentarios
Respuesta aceptada
Chad Gilbert
el 3 de Jul. de 2013
I'd tend to choose str2func, merely because it makes it more obvious what I'm anticipating as an output.
Más respuestas (1)
Shashank Prasanna
el 3 de Jul. de 2013
Don't use eval - EVER!
There is a whole documentation page that should answer 'why?'
Ver también
Categorías
Más información sobre Platform and License en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!