MATLAB Answers

how to store the intermediate result when using fmincon

13 views (last 30 days)
xueqi
xueqi on 30 Jan 2013
Answered: Daniel Frisch on 7 Oct 2020
Dear fellows, I am using fmincon to do optmization. Could you tell me how to look at and store the intermediate result when fmincon is trying different value? Well, I need to give an initial value for fmincon to start, and after that, it will try different value to find the optimized one. I want to check all those values that it tried and the corresponding results. Cheers

Accepted Answer

Shashank Prasanna
Shashank Prasanna on 30 Jan 2013
You can use OutputFcn to access values at each iteration.
See the following link for more information:
In the optionset you can use the function as below:
options = optimset('OutputFcn',@outfun)
  9 Comments
xueqi
xueqi on 5 Feb 2013
It needs to read in data in excel file. I can I also put into excel file here? Thanks!

Sign in to comment.

More Answers (3)

xueqi
xueqi on 5 Feb 2013
It needs to read in data in excel file. I can I also put into excel file here? Thanks!

Alan Weiss
Alan Weiss on 5 Feb 2013
Use the xlswrite function to export data to an Excel file.
Alan Weiss
MATLAB mathematical toolbox documentation

Daniel Frisch
Daniel Frisch on 7 Oct 2020
You can use my function outputFcn_global that saves all the intermediate results in a global variable, so you can inspect them later on.

Tags

Community Treasure Hunt

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

Start Hunting!