.NET-Datentypen in MATLAB
Wenn Sie eine .NET-Methode oder -Funktion aufrufen, konvertiert MATLAB automatisch die meisten primitiven MATLAB-Argumente in .NET-Typen. Geben Sie ein String-Array mit der Funktion cell weiter. Geben Sie Arrays anderer MATLAB-Typen mit der Funktion NET.createArray weiter. Sie können Struktur-Arrays, dünn besetzte Arrays oder komplexe Zahlen nicht an .NET-Methoden weitergeben.
MATLAB konvertiert automatisch primitive .NET-Rückgabetypen in äquivalente MATLAB-Typen (falls vorhanden). Rufen Sie zur Konvertierung eines System.String-Objekts die Funktion char auf. Wenn die .NET-Funktion ein Array zurückgibt, benutzen Sie die entsprechende numerische MATLAB-Funktion für rechteckige Arrays und die Funktion cell für unregelmäßige Arrays bevor die Daten in einem MATLAB-Befehl verwendet werden. Rufen Sie zur Konvertierung eines MATLAB-Wörterbuchs in ein entsprechendes .NET-Objekt die Funktion NET.createDictionary auf.
Funktionen
NET.createArray | Array for nonprimitive .NET types |
NET.createDictionary | Generic .NET Dictionary (Seit R2023a) |
NET.disableAutoRelease | Lock .NET object representing RunTime Callable Wrapper (COM wrapper) |
NET.enableAutoRelease | Unlock .NET object representing RunTime Callable Wrapper (COM wrapper) |
Themen
- Pass Data to .NET Objects
MATLAB converts method arguments into .NET types.
- Handle Data Returned from .NET Objects
Mapping C# .NET types to MATLAB types.
- Pass Numeric Arguments
MATLAB automatically converts .NET numeric data to and from equivalent MATLAB data.
- Pass System.String Arguments
Examples using
System.Stringarguments. - Pass Cell Arrays of .NET Data
Tips for working with contents of nested
System.Objectarrays in MATLAB. - Read Cell Arrays of Excel Spreadsheet Data
This example for Microsoft® .NET Framework shows how to convert columns of Microsoft Excel® spreadsheet data to MATLAB types.
- Pass System.Enum Arguments
Examples using
System.Enumarguments. - Pass System.Nullable Arguments
This example shows how to handle .NET methods with
System.Nullabletype arguments, whose underlying value type isdouble. - Pass Jagged Arrays
This example shows how to create a .NET jagged array of
System.Doubleusing theNET.createArrayfunction. - Convert Nested System.Object Arrays
This example shows how to use the
cellfunction to convert data in nestedSystem.Objectarrays. - 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
Use the
cellfunction to convertSystem.StringandSystem.Objectarrays to MATLAB cell arrays.
Fehlersuche
Limitations to Support of .NET Arrays
.NET features not supported in MATLAB.