How to use the @ function calling when the function is defined as a variable?

3 visualizaciones (últimos 30 días)
Hello,
I tried the following
Myfunction='runf'
[x,y,z]=@Myfunction
where runf id the real function
It did not work. Is this possible at all?
Thank you

Respuesta aceptada

Chunru
Chunru el 30 de Ag. de 2022
MyfunctionStr='rand'; %'runf'
Myfunction = str2func(MyfunctionStr);
%[x,y,z]=@Myfunction
x = Myfunction()
x = 0.7439
  4 comentarios
Torsten
Torsten el 30 de Ag. de 2022
Movida: Stephen23 el 30 de Ag. de 2022
[sol,fval] = GODLIKE(Myfunction,...
instead of
[sol,fval] = GODLIKE(@Myfunction,...

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by