Main Content

Java Data Type Conversions

Pass Java Data to MATLAB

This table shows how the MATLAB® engine API maps Java® data types to MATLAB data types.

Java TypeMATLAB Type for Scalar DataMATLAB Type for Array Data

boolean

logical

logical

bytes

int8

int8

short

int16

int16

int

int32

int32

long

int64

int64

float

single

single

double

double

double

char

char

char

java.lang.String

string

string

com.mathworks.matlab.types.Struct

struct

struct

com.mathworks.matlab.types.Complex

double

double

com.mathworks.matlab.types.HandleObject

MATLAB handle object

MATLAB handle object

com.mathworks.matlab.types.ValueObject

MATLAB value object

MATLAB value object

com.mathworks.matlab.types.CellStr

cellstr

cellstr

Nonrectangular (jagged) array

N/A

cell

Pass MATLAB Data to Java

This table shows how the MATLAB engine API maps MATLAB data types to Java data types.

MATLAB TypeJava Type for Scalar DataJava Type for Array Data

logical

Boolean

boolean[]

int8

Byte

byte[]

uint8

Byte

byte[]

int16

Short

short[]

uint16

Short

short[]

int32

Integer

int[]

uint32

Integer

int[]

int64

Long

long[]

uint64

Long

long[]

single

Float

float[]

double

Double

double[]

char

String

String

string

String

String[]

cellstr

String

String[]

Mixed cell array

N/A

Object[]

MATLAB handle object

com.mathworks.matlab.types.HandleObject

com.mathworks.matlab.types.HandleObject[]

MATLAB value object

com.mathworks.matlab.types.ValueObject

com.mathworks.matlab.types.ValueObject

Complex number

com.mathworks.matlab.types.Complex

com.mathworks.matlab.types.Complex[]

struct

com.mathworks.matlab.types.Struct

com.mathworks.matlab.types.Struct[]

Related Topics