title: Saving return values of function returning multiple variables in Matlab
body: <p>I have never used matlab before so excuse this very basic question.</p>
  
  <p>Basically I have a function that returns multiple variables, defined like so:</p>
  
  <pre><code>function [a, b, c]=somefunction(x, y, z)
  </code></pre>
  
  <p>I know I can get the return values as follows:</p>
  
  <pre><code>[a,b,c] = somefunction(1,2,3);
  </code></pre>
  
  <p>Now what I would like to do instead is save multiple runs of <code>somefunction</code> into an array and then retrieve them later. I tried:</p>
  
  <pre><code>results = [];
  results = [results somefunction(1,2,3)];
  results = [results somefunction(4,5,6)];
  </code></pre>
  
  <p>And then I tried accessing the individual runs as:</p>
  
  <pre><code>% access second run, i.e. somefunction(1,2,3) ?
  a = results(2, 1);
  b = results(2, 2);
  c = results(2, 3);
  </code></pre>
  
  <p>but this tells me that the index is out of bound because <code>size(results) = [1,99654]</code> (99654 is the number of results I need to save). So it does not appear to be an array? Sorry for this basic question, again I have never used matlab.</p>