See: Description
| Interface | Description |
|---|---|
| Disposable |
The
Disposable interface is implemented by all classes that contain
native resources that need to be freed. |
| MWComponentOption |
An option that can be applied to a component initialization option set (MWComponentOptions).
|
| Class | Description |
|---|---|
| Images |
Utility methods for manipulating MWArrays that contain image data.
|
| MWApplication |
The
MWApplication class can be used to initialize the global state of MCR. |
| MWArray |
The
MWArray class is the base class for all MATLAB array types. |
| MWCellArray |
The
MWCellArray class manages a native MATLAB cell array. |
| MWCharArray |
The
MWCharArray class manages a native MATLAB char array. |
| MWClassID |
The
MWClassID class enumerates all MATLAB array types. |
| MWComplexity |
The
MWComplexity class enumerates the MATLAB real/complex array property. |
| MWComponentOptions |
Options per component instance.
|
| MWCtfClassLoaderSource |
Class Description
|
| MWCtfDirectorySource |
CTF from directory where CTF file located at.
|
| MWCtfExtractLocation |
This class is used to represent the location where CTF will be extracted to.
|
| MWCtfFileSource |
CTF from file source
|
| MWCtfSource |
Interface for CTF source objects.
|
| MWCtfStreamSource |
CTF from InputStream source.
|
| MWFunctionHandle |
The
MWFunctionHandle class represents a MATLAB function handle. |
| MWJavaObjectRef |
MWJavaObjectRef, a special subclass of MWArray, can be used to create a
MATLAB array that references a Java object. |
| MWLogicalArray |
The
MWLogicalArray class manages a native MATLAB logical array. |
| MWMCROption |
This class represents the options that can be passed while initializing the MCR
|
| MWNumericArray |
The
MWNumericArray class is the base class for all numeric MATLAB array types. |
| MWStructArray |
The
MWStructArray class manages a native MATLAB struct array. |
| Exception | Description |
|---|---|
| MWException |
The
MWException class is used to raise an exception during a method
call on a MATLAB compiler generated object. |
This package provides classes that define the rules for data conversion between Java and MATLAB programming environment. It also has a few utility classes that allow you to change the MATLAB (MCR) environment that executes the underlying M-code.
In the MATLAB environment, a matrix is the basic building block for all the data types. There are scalars which are 1-by-1 matrices , vectors which are matrices with only one row or column and multi dimensional matrices with 2 or more dimensions. MATLAB has other ways of storing both numeric and nonnumeric data, but it is usually best to think of everything as a matrix.
The data types offered by MATLAB mainly include logical, char, numeric, cell, structure, function handles and java classes. The numeric data type has subtypes to represent signed and unsigned, integer and floating-point data. Cell and structure are MATLAB specific data types that act as the containers for different types of data. Each of the MATLAB data types is in the form of a matrix or array and is a minimum of 0-by-0 in size and can grow to an n-dimensional array of any size. For more information on MATLAB data types, please visit the MathWorks support Web site and refer the section "Programming Fundamentals"
For Java programmers, MATLAB Builder JA provides interface to MATLAB data types through a class hierarchy provided by this package. At the top of this class hierarchy lies MWArray, which is an abstract class. The concrete subclasses of MWArray represent one or more MATLAB data types. The MWArray class has the following subclasses representing the major MATLAB types: MWNumericArray, MWLogicalArray, MWCharArray, MWCellArray, MWStructArray, MWFunctionHandle and MWJavaObjectRef. An instance of one of these subclasses can represent either scalar, vector or multi dimensional underlying MATLAB data. Each class has functions that can be used to query the various attributes like dimensionality, size, the type of actual MATLAB data that it is representing, etc. There are also functions that can be used to get and set the underlying MATLAB data.
Following table lists the data conversion rules for converting Java data types to MATLAB types using MWArray class hierarchy
| Java type | MWArray type | MATLAB type |
|---|---|---|
| double, java.lang.Double | MWNumericArray | double |
| java.lang.Number | MWNumericArray | double |
| float, java.lang.Float | MWNumericArray | single |
| byte, java.lang.Byte | MWNumericArray | int8 |
| short, java.lang.Short | MWNumericArray | int16 |
| int, java.lang.Integer | MWNumericArray | int32 |
| long, java.lang.Long | MWNumericArray | int64 |
| char, java.lang.Character | MWCharArray | char |
| java.lang.String | MWCharArray | char |
| boolean, java.lang.Boolean | MWLogicalArray | logical |
| N/A | MWCellArray | cell |
| N/A | MWStructArray | structure |
Note: Java has no unsigned types to represent the uint8, uint16, uint32, and uint64 types used in MATLAB. Construction of and access to MATLAB arrays of an unsigned type requires conversion to appropriate types. Java does not have any built-in data type that can represent MATLAB specific cell and structure data types.
When you invoke a method, corresponding to an M functions, on a MATLAB Builder JA generated Java class instance, the input parameters received by the method must be in the MATLAB internal array format. You can either (manually) convert them yourself within the calling program, or pass the parameters as Java data types.
All data returned from the method call is received by the client Java application as an instance of the appropriate MWArray subclass. For example, a MATLAB cell array is returned to the Java application as an MWCellArray object. Return data is not converted to a Java type. If you choose to use a Java type, you must convert to that type using the toArray method of the MWArray subclass to which the return data belongs.
Instances of MWArray subtypes should be disposed of when no more needed. The special attention to the Memory Management is necessary due to the dependency of these classes on MCR. Following is a snippet of code from one of the examples shipped with MATLAB Builder JA that demonstrates how the memory management is performed for the MWArray types.
// magic is a class generated using MATLAB Builder JA that exposes
// M function makesqr
MWNumericArray n = null; // Stores input value
Object[] result = null; // Stores the result
magic theMagic = null; // Stores magic class instance
try
{
n = new MWNumericArray(Double.valueOf(args[0]),MWClassID.DOUBLE);
// Create new magic object
theMagic = new magic();
// Compute magic square
result = theMagic.makesqr(1, n);
}
catch (Exception e)
{
System.out.println("Exception: " + e.toString());
}
finally
{
// Free native resources
MWArray.disposeArray(n);
MWArray.disposeArray(result);
if (theMagic != null)
theMagic.dispose();
}
© 1994-2008 The MathWorks, Inc. Terms of Use Patents Trademarks