The cell array is a fairly powerful array type that is available
in FreeMat. Generally speaking, a cell array is a heterogenous
array type, meaning that different elements in the array can
contain variables of different type (including other cell arrays).
For those of you familiar with C, it is the equivalent to the
void * array. The general syntax for their construction is
A = {row_def1;row_def2;...;row_defN}
where each row consists of one or more elements, seperated by commas
row_defi = element_i1,element_i2,...,element_iM
Each element can be any type of FreeMat variable, including matrices, arrays, cell-arrays, structures, strings, etc. The restriction on the definition is that each row must have the same number of elements in it.
Here is an example of a cell-array that contains a number, a string, and an array
--> A = {14,'hello',[1:10]}
A =
<cell array> - size: [1 3]
Columns 1 to 3
[14] hello [[1 10] int32]
Note that in the output, the number and string are explicitly printed, but the array is summarized. We can create a 2-dimensional cell-array by adding another row definition
--> B = {pi,i;e,-1}
B =
<cell array> - size: [2 2]
Columns 1 to 2
[3.141593] [0.000000+1.000000i]
[2.718282] [-1]
Finally, we create a new cell array by placing A and B
together
--> C = {A,B}
C =
<cell array> - size: [1 2]
Columns 1 to 2
{[1 3] cell } {[2 2] cell }