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

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

 채택된 답변

MyfunctionStr='rand'; %'runf'
Myfunction = str2func(MyfunctionStr);
%[x,y,z]=@Myfunction
x = Myfunction()
x = 0.7439

댓글 수: 4

I tried this and it did not work. not sure what I am doing wrong.
Thank you
MyfunctionStr='rand'; %'runf'
Myfunction = str2func(MyfunctionStr);
[sol,fval] = GODLIKE(@Myfunction,...
transpose(variable_min_values(:,1)), transpose(variable_max_values(:,1)),...
[],...
'display', 'off','numobjectives', 2) ;
it says unrecognizable function Myfunction
[sol,fval] = GODLIKE(Myfunction,...
instead of
[sol,fval] = GODLIKE(@Myfunction,...

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Big Data Processing에 대해 자세히 알아보기

제품

릴리스

R2019b

질문:

2022년 8월 30일

댓글:

2022년 8월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by