How do I plot the values at every iteration of an optimization algorithm against the value of the function to be optimized

Hello,
I am using fmincon to find the optimal variables to minimize a certain function, f(x). I want to be able to see the values of the variables at every iteration along with the associated value of f(x). I cannot seem to find what the values are at every iteration. The PlotFcns option doesn't really help.
Any ideas?

2 Comments

Why wouldn't the PlotFcns option be what you need? Setting it to {@optimplotx, @optimplotfval} seems like it should do exactly what you're asking for.
because the optimplotx only shows me the values used at every iteration as it is happening. I can't store them so I can plot them with their respective f(x) value.

Sign in to comment.

Answers (1)

Use an output function. See this link.
Alan Weiss
MATLAB mathematical toolbox documentation

Categories

Asked:

on 20 Nov 2012

Community Treasure Hunt

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

Start Hunting!