필터 지우기
필터 지우기

Error with nested function to output history x values of FMINCON

조회 수: 4 (최근 30일)
Martha
Martha 2016년 2월 21일
댓글: Martha 2016년 2월 21일
Hello, I want to retrieve the values of x at each iteration of an optimization routine using FMINCON. I've defined a nested function to save in history variable the x values. But, when I run the code, It says that I don't have enough inputs in line 4, which is where I call the fmincon. This is the nested function:
function OptimalResult = iteroutfun(x0,t,e)
history = [];
options=optimset('Display','iter', 'FunValCheck','on', 'OutputFcn', @myoutput);
OptimalResult = fmincon(@(x) ObjFunction3a(x,t,e), x0, [], [], [], [], [], [], @(x)ConstraintsOR3a(x,e,t), options);
function stop = myoutput(x,optimvalues,state);
stop = false;
if isequal(state, 'iter')
history = [history; x];
end
end
end
If someone has any idea of what is that I'm missing I'll appreciate it very much,
Thank you, Martha
  댓글 수: 2
Walter Roberson
Walter Roberson 2016년 2월 21일
You do not show ObjFunction3a
Martha
Martha 2016년 2월 21일
Thank you Walter, I added the ObjFunction3a and the ConstraintsOR3a to the nested function and it worked well.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by