MATLAB: How to use OPTIMSET to display only the iteration number when executing an optimization function

Optimization Toolboxoutputfcn

In my optimization function, I would like to display just the iteration number after each iteration. To do that, I am setting the options for this function using
However, when I use this option the optimization function displays a lot of information regarding the optimization parameters along with iteration number. I would like to see only the iteration number and suppress all other information.

Best Answer

The ability to display only the iteration number and suppress other information using the 'Display' option in OPTIMSET function is not available in Optimization Toolbox 3.1 (R2006b).
To work around this issue, you can use the 'OutputFcn' option. The function specified in this field is called by the optimization function after each iteration.
As an example of this, see the attached file 'outfun.m'. To use 'outfun' as your 'OutputFcn', set the 'OutputFcn' option to 'outfun' as follows
opts = optimset('OutputFcn',@outfun);
Then, when you call the optimization function with 'opts' option structure created above, you will be able to see the iteration number at MATLAB command window after each iteration.
ow after each iteration.