Main Content

Pass .NET Data Types to MATLAB Functions

When you pass .NET data as input arguments to MATLAB® functions, the engine converts the data into equivalent MATLAB data types.

These tables show how the engine maps .NET data types to MATLAB data types.

Pass .NET Numeric Types to MATLAB

.NET Data Type (Scalar)

Resulting MATLAB Type (Scalar)

System.Double

double

System.Single

single

System.SByte

int8

System.Byte

uint8

System.Int16

int16

System.UInt16

uint16

System.Int32

int32

System.UInt32

uint32

System.Int64

int64

System.UInt64

uint64

System.Boolean

logical

Numerics.Complex

complex double
MATLAB does not support complex numbers for other numeric types.

MathWorks.MATLAB.Types.MATLABStruct

struct

.NET Data Type (1-D Vector)

Resulting MATLAB Type (1-D Vector)

System.Double[]

double

System.Single[]

single

System.SByte[]

int8

System.Byte[]

uint8

System.Int16[]

int16

System.UInt16[]

uint16

System.Int32[]

int32

System.UInt32[]

uint32

System.Int64[]

int64

System.UInt64[]

uint64

System.Boolean[]

logical

Numerics.Complex[]

complex double
MATLAB does not support complex numbers for other numeric types.

MathWorks.MATLAB.Types.MATLABStruct[]

struct[]

.NET Data Type (N-D Array)

Resulting MATLAB Type (N-D Array)

System.Double[,,...]

double

System.Single[,,...]

single

System.SByte[,,...]

int8

System.Byte[,,...]

uint8

System.Int16[,,...]

int16

System.UInt16[,,...]

uint16

System.Int32[,,...]

int32

System.UInt32[,,...]

uint32

System.Int64[,,...]

int64

System.UInt64[,,...]

uint64

System.Boolean[,,...]

logical

Numerics.Complex[,,...]

complex double
MATLAB does not support complex numbers for other numeric types.

MathWorks.MATLAB.Types.MATLABStruct[,,...]

struct[,,...]

Constants

Resulting MATLAB Value

System.Double.NaN

Result of NaN("double")

System.Single.NaN

Result of NaN("single")

System.Double.PositiveInfinity

Result of Inf("double")

System.Single.PositiveInfinity

Result of Inf("single")

System.Double.NegativeInfinity

Result of -Inf("double")

System.Single.NegativeInfinity

Result of -Inf("single")

Note

The .NET System.Decimal type is not supported for scalar, vector, or array arguments.

Pass .NET String and Character Types to MATLAB

.NET Data Type (Scalar)

Resulting MATLAB Type (Scalar)

System.String

string

System.Char

char

null System.String

<missing> value in string

.NET Data Type (1-D Vector)

Resulting MATLAB Type (1-D Vector)

System.String[]

string

System.Char[]

char

.NET Data Type (N-D Array)

Resulting MATLAB Type (N-D Array)

System.String[,,...]

string

System.Char[,,...]

char

Pass .NET System.Object to MATLAB

.NET Data Type

Resulting MATLAB Type

System.Object[]

1-D cell vector

System.Object[,,...]

N-D cell array

Pass .NET Handle and Value Objects to MATLAB

.NET Object TypeResulting MATLAB Type

MathWorks.MATLAB.Types.MATLABObject

scalar of underlying MATLAB type

MathWorks.MATLAB.Types.MATLABObject[]

1-D vector of underlying MATLAB type

MathWorks.MATLAB.Types.MATLABObject[,,...]

N-D array of underlying MATLAB type

Related Topics