cell and array in Matlab
- by Tim
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!