Undefined function 'Fun" for input argument of type 'double'?
이전 댓글 표시
function z=fun(U)
z='FPAeld1';
end
i need to call the first script from this algorithm but i'm getting error "undefined function 'Fun'.." why?
채택된 답변
추가 답변 (1개)
Walter Roberson
2015년 9월 9일
At the bottom you have
function z=fun(U)
z='FPAeld1';
end
Change that to
function z = Fun(U)
z = FPAeld1(U);
end
댓글 수: 8
Walter Roberson
2015년 9월 9일
function z = Fun(U)
global objfun
z = feval(objfun, U);
end
Better yet, do not use global variables. For example in your second script, do not have global objfun and instead have
objfun = @FPAeld1
and then change your
function [best,fmin,N_iter]=fpa_demo(para)
to
function [best,fmin,N_iter]=fpa_demo(para, Fun)
and do not have that "function Fun" at the end of the code.
JL555
2015년 9월 9일
JL555
2015년 9월 9일
Walter Roberson
2015년 9월 9일
I have not tried to run the code. You have not shown what should be passed to fpa_demo() . Your script does not call fpa_demo()
Yes, the lines
function z = Fun(U)
global objfun
z = feval(objfun, U);
end
would replace what you had as
function z=fun(U)
z='FPAeld1';
end
JL555
2015년 9월 9일
JL555
2015년 9월 9일
Steven Lord
2015년 9월 9일
카테고리
도움말 센터 및 File Exchange에서 Entering Commands에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!