access a variable from the last iteration of optimization function: fmincon
Mostrar comentarios más antiguos
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.
Respuestas (1)
Walter Roberson
el 3 de Abr. de 2011
0 votos
You could use "global" or "persistent" but note that fmincon doesn't promise to evaluate in any particular order.
2 comentarios
Ibehma01
el 3 de Abr. de 2011
Walter Roberson
el 3 de Abr. de 2011
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...
Categorías
Más información sobre Choose a Solver en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!