Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

function whose argument is a string containing name of respective function.

2 visualizaciones (últimos 30 días)
Aydin Ahmadli
Aydin Ahmadli el 13 de Nov. de 2018
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
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...

Respuestas (1)

James Tursa
James Tursa el 14 de Nov. de 2018
Editada: Stephen23 el 14 de Nov. de 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.

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by