How Does MATLAB Builder for Java H andle Data?
Overview of Classes and Methods in the Data Conversion
Class Hierarchy
The root of the data conversion class hierarchy is the MWArray abstract
class. The
MWArray class has the following subclasses representing the
major MATLAB types:
MWNumericArray, MWLogicalArray, MWCharArray,
MWCellArray,andMWStructArray.
Each subclass stores a reference to a native MATLAB array of that type.
Each class provides constructors and a basic set of methods for accessing
the underlying array’s properties and data. To be specific,
MWArray and the
classes derived from
MWArray pr ovide t he following:
• Constructors and finalizers to instantiate and dispose of MATLAB arrays
•
get and set methods to read and write the array data
• Methods to identify p roperties of the array
• Comparison methods to test the equality or order of the array
• Conversion methods to convert to other data types
Advantage of Using Data Conversion Classes
The MWArray data convers ion classes let you p ass native type p arameters
directly without using explicit data conversion. If y ou pass the same array
frequently, you might improve the performance of your program by storing
the array in an instance of one of the
MWArray subclasses.
Automatic Conversion to MATLAB Types
Note Because the conve rsio n process is a utomatic (in most cases), you do not
need to understand the conversion process to pass and return arguments with
MATLAB Builder for Java components.
When you pass an MWArray instan ce as an inp ut argument, the encapsu lated
MATLABarrayispasseddirectlytothemethodbeingcalled.
In contrast, if your code uses a native Java primitive or array as an input
parameter, Java Builder converts it to an instance of the appropriate
MWArray
2-5
Komentarze do niniejszej Instrukcji