La traduction de cette page n'est pas à jour. Cliquez ici pour voir la dernière version en anglais.
C Matrix API
mxArray
pour représenter les données MATLABPour écrire des programmes C qui fonctionnent avec MATLAB® R2017b ou version antérieure, utilisez les fonctions de C Matrix API. Ces fonctions utilisent la structure de données mxArray
et permettent de créer des fonctions MEX C ou des applications Engine C.
Remarque
Dans la mesure du possible, choisissez des applications C++ plutôt que C.
Il existe deux versions de C Matrix API.
Interleaved complex API contient les fonctionnalités de C Matrix API à partir de MATLAB R2018a. Pour plus d’informations, consultez MATLAB Support for Interleaved Complex API in MEX Functions.
Separate complex API contient les fonctionnalités de C Matrix API à partir de MATLAB R2017b.
Pour des exemples utilisant ces fonctions de bibliothèque, consultez :
Consultez les différentes fonctions pour voir des exemples correspondants. Par exemple, consultez
mxIsChar
.
Attention
C Matrix API n’est pas compatible avec MATLAB Data API pour C++ qui supporte les fonctionnalités du C++ moderne. Vous ne pouvez pas utiliser les fonctions de C Matrix API avec celles des API MATLAB décrites dans Écrire des fonctions C++ appelables depuis MATLAB (fichiers MEX) ou Appeler MATLAB à partir de C++.
Types de données C
mxArray | C type for MATLAB array |
mwSize | C type for mxArray size values |
mwIndex | C type for mxArray index values |
mwSignedIndex | Signed integer C type for mxArray size values |
mxChar | Type for string array |
mxLogical | Type for logical array |
mxComplexity | Flag specifying whether array has imaginary components |
Attributs mxArray
mxIsNumeric | Determine whether mxArray is numeric |
mxIsComplex | Determine whether data is complex |
mxGetNumberOfDimensions | Number of dimensions in mxArray |
mxGetElementSize | Number of bytes required to store each data element |
mxGetDimensions | Pointer to dimensions array |
mxSetDimensions | Modify number of dimensions and size of each dimension |
mxGetNumberOfElements | Number of elements in numeric mxArray |
mxCalcSingleSubscript | Offset from first element to desired element |
mxGetM | Number of rows in mxArray |
mxSetM | Set number of rows in mxArray |
mxGetN | Number of columns in mxArray |
mxSetN | Set number of columns in mxArray |
mxIsEmpty | Determine whether mxArray is empty |
mxIsFromGlobalWS | Determine whether mxArray was copied from MATLAB global workspace |
Créer et interroger des types de données et y accéder
Supprimer et dupliquer mxArray
mxDestroyArray | Free dynamic memory allocated by MXCREATE* functions |
mxDuplicateArray | Make deep copy of array |
Convertir mxArray
Gestion de la mémoire de données
mxCalloc | Allocate dynamic memory for array, initialized to 0, using MATLAB memory manager |
mxMalloc | Allocate uninitialized dynamic memory using MATLAB memory manager |
mxRealloc | Reallocate dynamic memory using MATLAB memory manager |
mxFree | Free dynamic memory allocated by mxCalloc, mxMalloc, mxRealloc, mxArrayToString, or mxArrayToUTF8String functions |
Assertions
Constantes
mxIsInf | Determine whether input is infinite |
mxIsFinite | Determine whether input is finite |
mxIsNaN | Determine whether input is NaN (Not-a-Number) |
Rubriques
- Pass Strings in C MEX File
This example shows how to pass strings to a MEX function built with the C Matrix API.
- Pass Scalar Values in C MEX File
This example shows how to write a MEX file that passes scalar values.
- Handle Sparse Arrays in C MEX File
This example shows how to populate a sparse matrix using the C Matrix API.
- Handle 8-, 16-, 32-, and 64-Bit Data in C MEX File
This example shows how to use unsigned 16-bit integers in a MEX file using the C Matrix API.
- Pass Structures and Cell Arrays in C MEX File
This example shows how to pass structures and cell arrays to MEX files built with the C Matrix API.
- Manipulate Multidimensional Numerical Arrays in C MEX Files
You can manipulate multidimensional numerical arrays by using typed data access functions like
mxGetDoubles
andmxGetComplexDoubles
.