- I don't know what the problem was with the OutputFcn, but this link gives an example almost identical to what you're talking about. In the OutputFcn in this example, the "history" structure dynamically accumulates the x and fval data and plots the x's.
- Since you say you want a "dynamic graph" I assume you want it to occur while the optimization is in progress. Therefore, the OutputFcn, and not the callback (and also not in your objective function), is the place to do that. The callback will only reacquire control of the program once the optimization has finished.
how to get and plot current "x" and "fval" during an fmincon optimization embedded in a GUI
4 views (last 30 days)
Show older comments
Hi,
I am writing an optimization code embedded in a GUI. Optimization works well at the moment, but I would like to improve the functionality of my GUI. In that context, I would like to plot a dynamic graph of "current point" and "current function value" of fmincon iterations on my GUI. My problems are:
1) I couldn't achieve to write an working Output function.
2) About GUI plot; I am not sure if I have to write plot command in my optimization function or in GUI callback
Thanks in advance
Sercan
0 Comments
Accepted Answer
Matt J
on 1 Nov 2012
4 Comments
Matt J
on 1 Nov 2012
OK, I don't know why the global variable approach wouldn't have worked, but it's always better not to use them.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!