Info
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
function whose argument is a string containing name of respective function.
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commento
Stephen23
il 14 Nov 2018
As an alternative, function handles are reccomended for passing functions as arguments:
Risposte (1)
James Tursa
il 14 Nov 2018
Modificato: Stephen23
il 14 Nov 2018
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 Commenti
Questa domanda è chiusa.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!