0

I have a function with two outputs as such

function [cost,correlation] = opt(beta, data, ind)

I am minimizing the cost function, using options with fmincon I can plot beta and cost at each iteration and they are saved. How can I do the same with correlation (even though it is not part of the optimization, I would like to track this)

rinkert
  • 6,593
  • 2
  • 12
  • 31
  • Do you want to plot the value of `correlation` during the optimization (i.e. after each iteration), or just see the change when the iteration is finished? Also, how do you currently save and plot `beta` and `cost`? – rinkert May 03 '19 at 13:47
  • yes I would like to plot it after each iteration and have it saved. I currently use options to plot cost and beta options = optimset('PlotFcns',{@optimplotfval,@optimplotx},'MaxIter',10); – Matthew Macfarlane May 03 '19 at 13:58

1 Answers1

0

You can define an output function that fmincon will call at every iteration. Details here and here

mcfenelon
  • 106
  • 2