User`s guide
4 Using MWArra y Classes
Guidelines for Wo rking with MWArray Classes
Overview of the MWArray API
The MWArray Java API is a class hierarchy that represents the major
MATLAB array types. The root class is
MWArray, which has the following
subclass es:
•
MWNumericArray
• MWLogicalArray
• MWCharArray
• MWCellArray
• MWStructArray
These subclasses provide constructors and factory methods for creating n ew
MATLAB arrays from standard Java types and objects. You can use these
MATLAB arrays as argu m en ts in me tho d calls.
Note To improve performance, MWArrays are designed so that they cannot be
resized or reshaped once they are created.
Understanding the MWArray Base Class
MWArray stores a reference to a native MATLAB array and provides a set of
methods for accessing the array’s properties and data.
MWArray also provides
methods for converting the MATLAB array to standard Java types from the
outputsofaJavaclassmethodcall.
Accessing Elements of the Arrays
You cannot access the underlying MATLAB array’s data buffers directly.
Instead use
set and get methods to retrieve or modify an element of the
array. The
set and get m ethods support simple indexing through a single
subscript (value at offset) or you can supply an array of
int representing the
indices of the requested value. In the case of structure arrays, i ndexing by
fieldnameisalsosupported.
4-2