com.mathworks.extern.java.MWCellArray Class
Namespace: com.mathworks.extern.java
Java class to manage MATLAB cell arrays
Description
Declaration
public class MWCellArray extends MWArray implements java.io.Serializable
MWCellArray class manages a native MATLAB® cell array. This class does not depend on MATLAB Runtime and should only be used in a Java® RMI based application where the client machine does not have MATLAB Runtime installed.
Creation
Constructors
MWCellArray()
Creates an empty cell array.
MWCellArray(int[] inDims)
Constructs a new cell array with the specified dimensions.
MWCellArray(int rows, int cols)
Constructs a new cell matrix with the specified number of rows and columns.
Properties
Public Properties
No public properties.
Methods
Examples
Create an Empty Cell Array
MWCellArray C = new MWCellArray();
System.out.println("C = " + C.toString());When run, the example displays this output:
C = []
Create a Cell Matrix with Rows and Columns
public MWCellArray(int rows,
int cols)Constructs a new cell matrix with the specified number of rows and columns.
Parameters
rows—Number of rows. Number of rows must be non-negative.
cols—Number of columns. Number of columns must be non-negative.
Throws
java.lang.NegativeArraySizeException—A negative row or column size is supplied.
Create Cell Array with Specified Dimensions
public MWCellArray(int[] inDims)Constructs a new cell array with the specified dimensions.
Parameters
inDims—Array of dimension sizes. Each dimension size must be non-negative.
Throws
java.lang.NegativeArraySizeException—A negative dimension size is supplied.
Example
int[] cdims = {2, 3};
MWCellArray C = new MWCellArray(cdims);
Integer[] val = new Integer[6];
for (int i = 0; i < 6; i++)
val[i] = new Integer(i * 15);
for (int i = 0; i < 2; i++)
for (int j = 0; j < 3; j++)
{
int[] idx = {i+1, j+1};
C.set(idx, val[j + (i * 3)]);
}
System.out.println("C = " + C.toString());When run, the example display this output:
C = 2x3 cell array
More About
Version History
Introduced in R2006a