User`s guide

4 Using MWArra y Classes
MWNumericArray a1 = new MWNumericArray(1.0);
MWNumericArray a2 = new MWNumericArray(1, MWClassID.DOUBLE);
MWNumericArray a3 = new MWNumericArray(new Double(1.0),
MWClassID.DOUBLE);
MWNumericArray a4 = new MWNumericArray("1.0", MWClassID.DOUBLE);
In general, it is most efficient to supply an argument that causes the desired
array to be created using the default conversion rules.
Some types require coercion to produce the correct MATLAB array. If you
supply an unsupported type to an
MWNumericArray constructor, an exception
is thrown and the array is not created.
The following example constructs a real 1-by-3
double array with the values
[1 2 3]:
double[] x1 = {1.0, 2.0, 3.0};
int[] x2 = {1, 2, 3};
Double[] x3 = {new Double(1.0), new Double(2.0),
new Double(3.0)};
String[] x4 = {"1.0", "2.0", "3.0"};
MWNumericArray a1 = new MWNumericArray(x1, MWClassID.DOUBLE);
MWNumericArray a2 = new MWNumericArray(x2, MWClassID.DOUBLE);
MWNumericArray a3 = new MWNumericArray(x3, MWClassID.DOUBLE);
MWNumericArray a4 = new MWNumericArray(x4, MWClassID.DOUBLE);
Using Static Factory Methods to Construct MWNumericArrays
An alternative method for constructing numeric arrays is to use the static
factory methods of the
MWNumericArray class. Thefollowingtablelistssuch
methods.
Factory Method Usage
newInstance(int[], MWClassID,
MWComplexity)
Numeric array of specified type and
complexity. Val ues are initia li zed to
0.
4-12