cell and array in Matlab

Posted by Tim on Stack Overflow See other posts from Stack Overflow or by Tim
Published on 2010-04-18T16:28:04Z Indexed on 2010/04/18 16:33 UTC
Read the original article Hit count: 249

Filed under:

Hi,

I am a little confused about the usage of cell and array in Matlab. I would like to hear about your understandings. Here are my observations:

(1). array can dynamically adjust its own memory to allow dynamic number of elements, while cell seems not act in the same way.

a=[]; a=[a 1]; b={}; b={b 1};

(2). several elements can be retrieved from cell, while they seem not from array.

a={'1' '2'}; figure, plot(...); hold on; plot(...) ; legend(a{1:2});   
b=['1' '2']; figure, plot(...); hold on; plot(...) ; legend(b(1:2));
% b(1:2) is an array, not its elements, so it is wrong with legend.

Are these correct? What are some other different usages between the cell and array?

Thanks and regards!

© Stack Overflow or respective owner

Related posts about matlab