Is there the more elegant way to do this?
显示 更早的评论
I would like to call arguments of function from a string or cell array. For example, this code works as I want:
function testarg()
a=1;b=2;c=3;
m='a,b,c';
eval(['myfun(',m,')']);
function myfun(a,b,c)
a
b
c
Is there another way to do this? Say, without using eval ?
2 个评论
Jos (10584)
2014-1-29
Just a tip: whenever you found yourself using eval, you will be 99.999% sure that there is a way to do it some other way without using eval that is:
- more efficient
- less error-prone
- without hideous side-effects
- easy to code, read and maintain
- ...
eval(char('chro''&HB@MCNVHSGNTSDU@K &('+1))
采纳的回答
更多回答(1 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!