La traduction de cette page n'est pas à jour. Cliquez ici pour voir la dernière version en anglais.
Types de données .NET dans MATLAB
Lorsque vous appelez une méthode ou fonction .NET, MATLAB convertit automatiquement la plupart des arguments primitifs MATLAB en types .NET. Pour transmettre un tableau de chaînes de caractères, utilisez la fonction cell
. Pour transmettre des tableaux d’autres types MATLAB, utilisez la fonction NET.createArray
. Vous ne pouvez pas transmettre de tableaux de structure, de tableaux creux ni de nombres complexes aux méthodes .NET.
MATLAB convertit automatiquement les types de retour .NET primitifs en types MATLAB équivalents, s’ils existent. Pour convertir un objet System.String
, appelez la fonction char
. Si la fonction .NET renvoie un tableau, avant d’utiliser les données dans une commande MATLAB, utilisez la fonction numérique MATLAB correspondante pour les rectangular array ou la fonction cell
pour les jagged array. Pour convertir un dictionnaire MATLAB en objet .NET correspondant, appelez la fonction NET.createDictionary
.
Fonctions
NET.createArray | Array for nonprimitive .NET types |
NET.createDictionary | Generic .NET Dictionary (depuis R2023a) |
NET.disableAutoRelease | Lock .NET object representing RunTime Callable Wrapper (COM wrapper) |
NET.enableAutoRelease | Unlock .NET object representing RunTime Callable Wrapper (COM wrapper) |
Rubriques
- 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.String
arguments. - Pass Cell Arrays of .NET Data
Tips for working with contents of nested
System.Object
arrays 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.Enum
arguments. - Pass System.Nullable Arguments
This example shows how to handle .NET methods with
System.Nullable
type arguments, whose underlying value type isdouble
. - Pass Jagged Arrays
This example shows how to create a .NET jagged array of
System.Double
using theNET.createArray
function. - Convert Nested System.Object Arrays
This example shows how to use the
cell
function to convert data in nestedSystem.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
Use the
cell
function to convertSystem.String
andSystem.Object
arrays to MATLAB cell arrays.
Résolution des problèmes
Limitations to Support of .NET Arrays
.NET features not supported in MATLAB.