Info
此问题已关闭。 请重新打开它进行编辑或回答。
function whose argument is a string containing name of respective function.
2 次查看(过去 30 天)
显示 更早的评论
I have simple question:
function m=forexample('hey')
Above, 'hey' is string containing name of the respective function. How can I evaluate respective function 'hey' in main function? They say, function feval might be useful, but i dont know how to use it...
1 个评论
Stephen23
2018-11-14
As an alternative, function handles are reccomended for passing functions as arguments:
回答(1 个)
James Tursa
2018-11-14
编辑:Stephen23
2018-11-14
E.g.,
>> sind(30)
ans =
0.5000
>> s = 'sind';
>> feval(s,30)
ans =
0.5000
So, if you pass an argument into your forexample function, simply use that argument as the first argument to feval.
0 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!