Save output from 'Display' option when using fminsearch to object

I am using fminsearch to find the minimum of an objective function, but I want to be able to store the progress at each iteration in terms of the function value/action taken at that iteration. The following code prints out the information I want to the matlab terminal,
options = optimset('Display','iter')
[x,fval,exitflag,output] = fminsearch(fun,x0,options)
though I don't know how to save it to an object that I can use later on for analysis. Is this possible?
Thanks

 Accepted Answer

Matt J
Matt J on 31 Oct 2017
Edited: Matt J on 31 Oct 2017
You should use the OutputFcn option, specifically, to save the optimValues inputs automatically fed to the Output Function that you specify.

More Answers (1)

If you do not need to be able to see the output as it is produced, then you can use evalc().
If you do need to be able to see the output as it is produced, then diary()

2 Comments

What should be passed to the evalc() function?
data = evalc(fminsearch(fun,x0,options))
returns the error
Undefined function 'evalc' for input arguments of type 'double'.
and I don't see what else I can give it.
Thanks
output = evalc('[x,fval,exitflag,output] = fminsearch(fun,x0,options);')

Sign in to comment.

Categories

Find more on Simulink Design Optimization in Help Center and File Exchange

Asked:

on 31 Oct 2017

Edited:

on 31 Oct 2017

Community Treasure Hunt

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

Start Hunting!