title: What's better for performance, cell arrays of objects or heterogeneous arrays?
body: <p>Suppose I have some classes <code>foo &lt; handle</code>, and <code>bar &lt; foo</code>, <code>baz &lt; foo</code>, and maybe <code>qux &lt; foo</code>. There are a couple ways I can store an array of these objects:</p>
  
  <ul>
  <li><p>As a cell array: <code>A = {foo bar baz qux} % A(1) would be a cell, A{1} gives me a foo object</code></p></li>
  <li><p>Starting with R2011a, I can make <code>foo &lt;</code><a href="http://www.mathworks.com/help/matlab/ref/matlab.mixin.heterogeneous-class.html"><code>matlab.mixin.Heterogeneous</code></a>, and then build an array directy: <code>A = [foo bar baz qux] % A(1) directly gives me a foo object</code></p></li>
  </ul>
  
  <p>The way I see it, from a maintenance perspective it would be better to use the second method rather than the first, this way it removes ambiguity about how to access <code>A</code>. Namely, when we need to dereference elements of the cell array (cell <code>A(1)</code> vs <code>foo</code> object <code>A{1}</code>, which lives inside <code>A(1)</code>).</p>
  
  <p>But is there any kind of memory or performance penalty (or benefit) to using one syntax vs the other?</p>