.NET Data Types in MATLAB
When you call a .NET method or function, MATLAB automatically converts most primitive MATLAB arguments into .NET types. To pass an array of strings, use the cell function. To pass arrays of other MATLAB types, use the NET.createArray function. You cannot
pass structure arrays, sparse arrays, or complex numbers to .NET methods.
MATLAB automatically converts primitive .NET return types to equivalent MATLAB types, if they exist. To convert a System.String object,
call the char function. If the .NET function returns an array, before
using the data in a MATLAB command, use the corresponding MATLAB numeric function for rectangular arrays, or the cell
function for jagged arrays. To convert a MATLAB dictionary to a corresponding .NET object, call the
NET.createDictionary function.
Functions
NET.createArray | Array for nonprimitive .NET types |
NET.createDictionary | Create generic .NET dictionary (Since R2023a) |
NET.disableAutoRelease | Lock .NET object representing Runtime Callable Wrapper (COM wrapper) |
NET.enableAutoRelease | Unlock .NET object representing Runtime Callable Wrapper (COM wrapper) |
Topics
- Pass MATLAB Data to .NET Functions
MATLAB converts .NET function arguments into .NET types.
- Handle Data Returned from .NET Objects
Mapping C# .NET types to MATLAB types.
- Pass System.String Arguments
Examples using
System.Stringarguments. - Use Cell Arrays of .NET Data
Tips for working with contents of nested
System.Objectarrays in MATLAB. - Read Cell Arrays of .NET Excel Spreadsheet Data
This example for Microsoft® .NET Framework shows how to convert columns of Microsoft Excel® spreadsheet data to MATLAB types.
- Use MATLAB Arrays with .NET Functions
Pass MATLAB arrays to .NET functions and convert data returned from .NET functions to MATLAB arrays.
- Pass Jagged Arrays
Examples using .NET jagged arrays.
- Pass System.Nullable Arguments
Examples using
System.Nullablearguments.
Troubleshooting
Limitations to Support of .NET Arrays
.NET features not supported in MATLAB.