Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
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

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by