This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Data Types

Data conversion, pass data between MATLAB® and .NET

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.


cellCell array
NET.createArrayArray for nonprimitive .NET types
NET.disableAutoReleaseLock .NET object representing a RunTime Callable Wrapper (COM Wrapper) so that MATLAB does not release COM object
NET.enableAutoReleaseUnlock .NET object representing a RunTime Callable Wrapper (COM Wrapper) so that MATLAB releases COM object


Pass Data to .NET Objects

When you call a .NET method or function from MATLAB, MATLAB automatically converts arguments into .NET types.

Handle Data Returned from .NET Objects

The following table shows how MATLAB converts data from a .NET object into MATLAB types.

Pass Numeric Arguments

MATLAB automatically converts .NET numeric data to and from equivalent MATLAB data.

Pass System.String Arguments

If an input argument to a .NET method is System.String, you can pass a MATLAB character array.

Pass Cell Arrays of .NET Data

In the Convert Nested System.Object Arrays example, the cell array mlData contains data from the MyGraph.getNewData method.

Read Cell Arrays of Excel Spreadsheet Data

This example shows how to convert columns of Microsoft® Excel® spreadsheet data to MATLAB types.

Pass System.Enum Arguments

An example of an enumeration is System.DayOfWeek.

Pass System.Nullable Arguments

This example shows how to handle .NET methods with System.Nullable type arguments, whose underlying value type is double.

Pass Jagged Arrays

This example shows how to create a .NET jagged array of System.Double using the NET.createArray function.

Convert Nested System.Object Arrays

This example shows how to use the cell function to convert data in nested System.Object arrays.

Use Arrays with .NET Applications

MATLAB automatically converts arrays to .NET types, as described in the MATLAB Primitive Type Conversion Table.

Convert .NET Arrays to Cell Arrays

To convert .NET System.String and System.Object arrays to MATLAB cell arrays, use the cell function.


Limitations to Support of .NET Arrays

MATLAB does not support:

Was this topic helpful?