Rules for Data Conversion Between Java and MATLAB
Java to MATLAB Conversion
The following table lists the data conversion rules for converting Java® data types to MATLAB® types. The conversion rules apply to scalars, vectors, matrices, and multidimensional arrays of the types listed.
The rules apply not only when calling your own methods, but also when calling
constructors and factory methods belonging to the MWArray
classes.
Note
When you call an MWArray
class method constructor, supplying a
specific data type causes the compiler to convert to that type instead of the
default.
Java to MATLAB Conversion Rules
Java Type | MATLAB Type |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Note Subclasses of |
|
|
|
|
|
Note A Java string is converted to a
An array of Java strings ( Higher dimensional arrays of In general, an |
MATLAB to Java Conversion
The following table lists the data conversion rules for converting MATLAB data types to Java types.
Note
The conversion rules apply to scalars, vectors, matrices, and multidimensional arrays of the types listed.
MATLAB to Java Conversion Rules
MATLAB Type | Java Type (Primitive) | Java Type (Object) |
---|---|---|
cell | Not applicable |
Note Cell arrays are constructed and accessed as arrays of
|
structure | Not applicable |
Note Structure arrays are constructed and accessed as arrays of
|
char | char | java.lang.Character |
double | double | java.lang.Double |
single | float | java.lang.Float |
int8 | byte | java.lang.Byte |
int16 | short |
|
int32 | int | java.lang.Integer |
int64 | long | java.lang.Long |
uint8 | byte |
Java has no unsigned type to represent the
|
uint16 |
|
Java has no unsigned type to represent the
|
uint32 | int |
Java has no unsigned type to represent the
|
uint64 | long |
Java has no unsigned type to represent the
|
logical | boolean | java.lang.Boolean |
Function handle | Not supported | |
Java class | Not supported | |
User class | Not supported |
Unsupported MATLAB Array Types
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.