Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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

Risposta accettata

Chunru
Chunru il 30 Ago 2022
MyfunctionStr='rand'; %'runf'
Myfunction = str2func(MyfunctionStr);
%[x,y,z]=@Myfunction
x = Myfunction()
x = 0.7439
  4 Commenti
Torsten
Torsten il 30 Ago 2022
Spostato: Stephen23 il 30 Ago 2022
[sol,fval] = GODLIKE(Myfunction,...
instead of
[sol,fval] = GODLIKE(@Myfunction,...

Accedi per commentare.

Più risposte (0)

Prodotti


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by