Suppose I have some classes foo < handle
, and bar < foo
, baz < foo
, and maybe qux < foo
. There are a couple ways I can store an array of these objects:
As a cell array:
A = {foo bar baz qux} % A(1) would be a cell, A{1} gives me a foo object
Starting with R2011a, I can make
foo <
matlab.mixin.Heterogeneous
, and then build an array directy:A = [foo bar baz qux] % A(1) directly gives me a foo object
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 A
. Namely, when we need to dereference elements of the cell array (cell A(1)
vs foo
object A{1}
, which lives inside A(1)
).
But is there any kind of memory or performance penalty (or benefit) to using one syntax vs the other?
whos
to see their respective sizes. – Psoasfoo
object by itself seems to also take up 104 bytes. So I guess don't really understand what is going on inside the heterogeneous implementation... – Coif