access a variable from the last iteration of optimization function: fmincon
이전 댓글 표시
I am using "fmincon" to optimize an objective function. MATLAB does iteration until one of the exit criteria happens. What I need is to use the value of a variables in my "objective function" code from the last step in current step. Actually, I wanna know if one variable in current step is equal to its value of the previous steps. I am grateful for any help.
답변 (1개)
Walter Roberson
2011년 4월 3일
0 개 추천
You could use "global" or "persistent" but note that fmincon doesn't promise to evaluate in any particular order.
댓글 수: 2
Ibehma01
2011년 4월 3일
Walter Roberson
2011년 4월 3일
You need to assign the new value to the global variable before leaving the evaluation function.
You can detect that you are on the first iteration of the function because the global variable will have the empty array for its value. Unless, of course, you ran the function before in the same session without clearing the global variable...
카테고리
도움말 센터 및 File Exchange에서 Choose a Solver에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!