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) |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| complex |
|
|
.NET Data Type (1-D Vector) | Resulting MATLAB Type (1-D Vector) |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| complex |
|
|
.NET Data Type (N-D Array) | Resulting MATLAB Type (N-D Array) |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| complex |
|
|
Constants | Resulting MATLAB Value |
---|---|
System.Double.NaN | Result of |
System.Single.NaN | Result of |
System.Double.PositiveInfinity | Result of |
System.Single.PositiveInfinity | Result of |
System.Double.NegativeInfinity | Result of |
System.Single.NegativeInfinity | Result of |
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) |
---|---|
|
|
|
|
null |
|
.NET Data Type (1-D Vector) | Resulting MATLAB Type (1-D Vector) |
---|---|
|
|
|
|
.NET Data Type (N-D Array) | Resulting MATLAB Type (N-D Array) |
---|---|
|
|
|
|
Pass .NET Dictionary
to MATLAB
To convert a .NET object to a MATLAB dictionary:
The type of the object implements the
System.Collections.Generic.IDictionary<TKey,TValue>
interface exactly once.For each dictionary entry, the key (
TKey
) must be a numeric, boolean, or string type.For each dictionary entry, the value (
TValue
) can be converted to a MATLAB data type using the conversion rules in Pass .NET Data Types to MATLAB Functions.The resulting dictionary must be a valid MATLAB dictionary. An example of an invalid dictionary is one that contains two values of different classes that are not heterogeneous.
For examples, see Use MATLAB Dictionary Objects in .NET.
.NET Data Type | Resulting MATLAB Type |
---|---|
|
|
The type of keys (TKey
) and values (TValue
) must
be one of these types, resulting in these conversions:
.NET Type | C# Keyword | Resulting MATLAB Type | Restrictions |
---|---|---|---|
System.Boolean | bool | logical | None |
System.SByte | sbyte | int8 | None |
System.Byte | byte | uint8 | None |
System.Int16 | short | int16 | None |
System.UInt16 | ushort | uint16 | None |
System.Int32 | int | int32 | None |
System.UInt32 | uint | uint32 | None |
System.Int64 | long | int64 | None |
System.UInt64 | ulong | uint64 | None |
System.Single | float | single | None |
System.Double | double | double | None |
System.Char | char | string | None |
System.String | string | string | None |
MathWorks.MATLAB.Types.MATLABObject | None | value or handle class | Not supported as keys |
MathWorks.MATLAB.Types.MATLABStruct | None | struct | |
System.Object | object | cell |
Pass .NET System.Object
to MATLAB
.NET Data Type | Resulting MATLAB Type |
---|---|
| 1-D cell vector |
| N-D cell array |
Pass .NET Handle and Value Objects to MATLAB
.NET Object Type | Resulting MATLAB Type |
---|---|
| scalar of underlying MATLAB type |
| 1-D vector of underlying MATLAB type |
| N-D array of underlying MATLAB type |