MATLAB API Libraries

The Matrix Library and the MEX Library describe functions you can use in your gateway and computational routines that interact with MATLAB® programs and the data in the MATLAB workspace. These libraries are part of the MATLAB C/C++ and Fortran API Reference library.

To use these functions, include the mex header, which declares the entry point and interface routines. Put this statement in your source file:

#include "mex.h"

Matrix Library

Use Matrix Library functions to pass mxArray, the type MATLAB uses to store arrays, to and from MEX-files. For examples using these functions, see matlabroot/extern/examples/mx.

MEX Library

Use MEX Library functions to perform operations in the MATLAB environment. For a list of the C functions, see C/C++ Source Files. For examples using these functions, see matlabroot/extern/examples/mex.

Unlike MATLAB functions, MEX-file functions do not have their own variable workspace. MEX-file functions operate in the caller's workspace. Use mexEvalString to evaluate the string in the caller's workspace. Use the mexGetVariable and mexPutVariable functions to get and put variables into the caller's workspace.

Preprocessor Macros

The Matrix and MEX libraries use the MATLAB preprocessor macros mwSize and mwIndex for cross-platform flexibility. mwSize represents size values, such as array dimensions and number of elements. mwIndex represents index values, such as indices into arrays.

See Also

| | | | | | |

More About

Was this topic helpful?