When is it appropriate to use a cell array vs. a struct in Matlab?

Viewed 22655

If I want to store some strings or matrices of different sizes in a single variable, I can think of two options: I could make a struct array and have one of the fields hold the data,

structArray(structIndex).structField

or I could use a cell array,

cellArray{cellIndex}

but is there a general rule-of-thumb of when to use which data structure? I'd like to know if there are downsides to using one or the other in certain situations.

4 Answers
Related