User`s guide

4 Using MWArra y Classes
Using MWCellArray Constructors
The MWCellArray class provides the following constructors:
Constructor Usage
MWCellArray()
Empty cell array.
MWCellArray(int[])
New cell array with specified dimensions. All
cells are initialized to empty.
MWCellArray(gint, int)
New cell matrix with specified number of rows
and columns.
Constructing a cell a rray is a two-step process. First, allocate the array using
one of the constructors in the previous table, then assign values to each cell
using one of the
set methods.
Constructing an MW CellArra y. For simple arrays, passing a Java array
directly is the most convenient approach. When you want to assign a more
complicated type to a cell (i.e., a complex array or another cell array), you
must create a temporary
MWArray for the input value. You should dispose of
any temporary arrays after assigning them to a cell.
This example creates and initializes a 2-by-2 cell array:
String x11 = "A String";
double[][] x12 = {{1.0, 2.0},
{3.0, 4.0}};
int[][] x21 = {{1, 2},
{3, 4}};
boolean[][] x22 = {{true, false},
{false, true}};
int[] index = {1, 1};
a.set(index, x11);
index[1] = 2;
a.set(index, x12);
index[0] = 2;
a.set(index, x22);
index[1] = 1;
a.set(index, x21);
4-32