title: How to code an output function for genetic algorithm in Matlab global optimization toolbox
body: <p>I am having some problems with writing an output function for genetic algorithm in Matlab global optimization toolbox.</p>
  <p>I want to create a function that stores all <code>state.Population</code> (each individual) of each generation.</p>
  <p>Here is what i know:</p>
  <p>Output functions are functions that the genetic algorithm calls at each generation.</p>
  <p>The output function has the following calling syntax.</p>
  <pre><code>[state,options,optchanged] = myfun(options,state,flag,interval)
  </code></pre>
  <p>From <a href="http://www.mathworks.com/help/releases/R2010b/toolbox/gads/f6174dfi10.html#f17837" rel="nofollow noreferrer">http://www.mathworks.com/help/releases/R2010b/toolbox/gads/f6174dfi10.html#f17837</a></p>
  <p>Where state contains useful data of the current generation.</p>
  <p>Here is what i've tried:</p>
  <p>Create a function with a different output than <code>[state,options,optchanged]</code>. The output is a global matrix that stores every <code>state.Population</code></p>