Cell Arrays
Cell arrays are generic data containers.
They are similar to matrices in that they have rows and columns, and specific elements can be accessed via one or more indices. The major difference is that the data in cell arrays does not have to be homogeneous. A cell can store a matrix, string, scalar, or even another cell array.
Cell arrays are defined using the {} operators. Elements in cell arrays are separated by
commas (or spaces) and semi-colons (or newlines), just like
matrices.
a={ [1,2;3,4], 'hello'; 5,[1,2,3] }
a is
a 2x2 cell array.To access the contents of a particular cell, the {} operators are used
again.
a{2,1} => 5
Elements can be directly assigned into cells using two different syntaxes, both involving
the {} operators.
a(2,2) = { [1,2,3]}
a{2,2} = [1,2,3]
These two
statements are equivalent.The size function can be used to determine the number of rows and columns in a cell array (just like for other entities).
To delete cells in a cell array, set the index (using the () index) of the spot being
deleted to [ ].
a(2,2) = {[]}
To set a cell to an empty matrix, set the index (using the {} index) of the stop being set
to an empty matrix to [ ].
a{2,2} = []
An empty cell is created using just curly braces ({})
a={}