Main Content

Data Type Mappings Between .NET and Strongly Typed MATLAB Code

C# to MATLAB

This table shows the mapping of C# data types to strongly typed MATLAB® data types.

DescriptionC# Data Type MATLAB Data Type Representation

Real double

  • scalar

  • vector

  • array


  • System.Double

  • System.Double[]

  • System.Double[,,...]


  • (1,1) double {mustBeReal}

  • (1,:) double {mustBeReal}

  • (1,:,:,...) double {mustBeReal}

Complex double

  • scalar

  • vector

  • array

MATLAB does not support complex numbers for other numeric types.


  • Numerics.Complex

  • Numerics.Complex[]

  • Numerics.Complex[,,...]


  • (1,1) double

  • (1,:) double

  • (1,:,:,...) double

Real single

  • scalar

  • vector

  • array


  • System.Single

  • System.Single[]

  • System.Single[,,...]


  • (1,1) single {mustBeReal}

  • (1,:) single {mustBeReal}

  • (1,:,:,...) single {mustBeReal}

Real integer

  • scalar

  • vector

  • array

  • System.SByte

  • System.SByte[]

  • System.SByte[,,...]

  • System.Int16

  • System.Int16[]

  • System.Int16[,,...]

  • System.Int32

  • System.Int32[]

  • System.Int32[,,...]

  • System.Int64

  • System.Int64[]

  • System.Int64[,,...]

  • System.Byte

  • System.Byte[]

  • System.Byte[,,...]

  • System.UInt16

  • System.UInt16[]

  • System.UInt16[,,...]

  • System.UInt32

  • System.UInt32[]

  • System.UInt32[,,...]

  • System.UInt64

  • System.UInt64[]

  • System.UInt64[,,...]

  • (1,1) int8 {mustBeReal}

  • (1,:) int8 {mustBeReal}

  • (1,:,:,...) int8 {mustBeReal}

  • (1,1) int16 {mustBeReal}

  • (1,:) int16 {mustBeReal}

  • (1,:,:,...) int16 {mustBeReal}

  • (1,1) int32 {mustBeReal}

  • (1,:) int32 {mustBeReal}

  • (1,:,:,...) int32 {mustBeReal}

  • (1,1) int64 {mustBeReal}

  • (1,:) int64 {mustBeReal}

  • (1,:,:,...) int64 {mustBeReal}

  • (1,1) uint8 {mustBeReal}

  • (1,:) uint8 {mustBeReal}

  • (1,:,:,...) uint8 {mustBeReal}

  • (1,1) uint16 {mustBeReal}

  • (1,:) uint16 {mustBeReal}

  • (1,:,:,...) uint16 {mustBeReal}

  • (1,1) uint32 {mustBeReal}

  • (1,:) uint32 {mustBeReal}

  • (1,:,:,...) uint32 {mustBeReal}

  • (1,1) uint64 {mustBeReal}

  • (1,:) uint64 {mustBeReal}

  • (1,:,:,...) uint64 {mustBeReal}

Logical

  • scalar

  • vector

  • array


  • System.Boolean

  • System.Boolean[]

  • System.Boolean[,,...]


  • (1,1) logical

  • (1,:) logical

  • (1,:,:,...) logical

Char

  • scalar

  • vector

  • array


  • System.Char

  • System.Char[]

  • System.Char[,,...]


  • (1,1) char

  • (1,:) char

  • (1,:,:,...) char

String

  • scalar

  • vector

  • array


  • System.String

  • System.String[]

  • System.String[,,...]


  • (1,1) string

  • (1,:) string

  • (1,:,:,...) string

Enum

  • scalar

  • vector

  • array


  • System.Enum

  • System.Enum[]

  • System.Enum[,,...]


  • (1,1) MyEnumClass

  • (1,:) MyEnumClass

  • (1,:,:,...) MyEnumClass

MATLAB to C#

This table shows the mapping of strongly typed MATLAB data types to C# data types.

Description MATLAB Data TypeC# Data Type Representation

Real double

  • scalar

  • vector

  • array


  • (1,1) double {mustBeReal}

  • (1,:) double {mustBeReal}

  • (1,:,:,...) double {mustBeReal}


  • System.Double

  • System.Double[]

  • System.Double[,,...]

Complex double

  • scalar

  • vector

  • array

Stored as a complex number, even if result is real


  • (1,1) double

  • (1,:) double

  • (1,:,:,...) double


  • Numerics.Complex

  • Numerics.Complex[]

  • Numerics.Complex[,,...]

Real single

  • scalar

  • vector

  • array


  • (1,1) single {mustBeReal}

  • (1,:) single {mustBeReal}

  • (1,:,:,...) single {mustBeReal}


  • System.Single

  • System.Single[]

  • System.Single[,,...]

Real integer

  • scalar

  • vector

  • array

  • (1,1) int8 {mustBeReal}

  • (1,:) int8 {mustBeReal}

  • (1,:,:,...) int8 {mustBeReal}

  • (1,1) int16 {mustBeReal}

  • (1,:) int16 {mustBeReal}

  • (1,:,:,...) int16 {mustBeReal}

  • (1,1) int32 {mustBeReal}

  • (1,:) int32 {mustBeReal}

  • (1,:,:,...) int32 {mustBeReal}

  • (1,1) int64 {mustBeReal}

  • (1,:) int64 {mustBeReal}

  • (1,:,:,...) int64 {mustBeReal}

  • (1,1) uint8 {mustBeReal}

  • (1,:) uint8 {mustBeReal}

  • (1,:,:,...) uint8 {mustBeReal}

  • (1,1) uint16 {mustBeReal}

  • (1,:) uint16 {mustBeReal}

  • (1,:,:,...) uint16 {mustBeReal}

  • (1,1) uint32 {mustBeReal}

  • (1,:) uint32 {mustBeReal}

  • (1,:,:,...) uint32 {mustBeReal}

  • (1,1) uint64 {mustBeReal}

  • (1,:) uint64 {mustBeReal}

  • (1,:,:,...) uint64 {mustBeReal}

  • System.SByte

  • System.SByte[]

  • System.SByte[,,...]

  • System.Int16

  • System.Int16[]

  • System.Int16[,,...]

  • System.Int32

  • System.Int32[]

  • System.Int32[,,...]

  • System.Int64

  • System.Int64[]

  • System.Int64[,,...]

  • System.Byte

  • System.Byte[]

  • System.Byte[,,...]

  • System.UInt16

  • System.UInt16[]

  • System.UInt16[,,...]

  • System.UInt32

  • System.UInt32[]

  • System.UInt32[,,...]

  • System.UInt64

  • System.UInt64[]

  • System.UInt64[,,...]

Logical

  • scalar

  • vector

  • array


  • (1,1) logical

  • (1,:) logical

  • (1,:,:,...) logical


  • System.Boolean

  • System.Boolean[]

  • System.Boolean[,,...]

Char

  • scalar

  • vector

  • array


  • (1,1) char

  • (1,:) char

  • (1,:,:,...) char


  • System.Char

  • System.Char[]

  • System.Char[,,...]

String

  • scalar

  • vector

  • array


  • (1,1) string

  • (1,:) string

  • (1,:,:,...) string


  • System.String

  • System.String[]

  • System.String[,,...]

Enum

  • scalar

  • vector

  • array


  • (1,1) MyEnumClass

  • (1,:) MyEnumClass

  • (1,:,:,...) MyEnumClass


  • System.Enum

  • System.Enum[]

  • System.Enum[,,...]

MATLAB cell

  • scalar

  • vector

  • array


  • (1,1) cell

  • (1,:) cell

  • (1,:,:,...) cell


  • System.Object

  • System.Object[]

  • System.Object[,,...]

For MATLAB types that do not have a corresponding C# type, such as struct or dictionary, the generated type is dynamic.

See Also

|

Related Topics