What would you do?
Afficher commentaires plus anciens
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?
Réponse acceptée
Plus de réponses (1)
Shashank Prasanna
le 3 Juil 2013
1 vote
Don't use eval - EVER!
There is a whole documentation page that should answer 'why?'
1 commentaire
Kye Taylor
le 8 Juil 2013
Catégories
En savoir plus sur Data Type Identification dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!