What would you do?
显示 更早的评论
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?
采纳的回答
更多回答(1 个)
Shashank Prasanna
2013-7-3
1 个投票
Don't use eval - EVER!
There is a whole documentation page that should answer 'why?'
类别
在 帮助中心 和 File Exchange 中查找有关 Data Type Identification 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!