text: Use Matrix Library and the MEX Library functions in gateway and computational routines to interact with 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"
  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
  Use MEX Library functions to perform operations in the MATLAB environment.
  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
  workspace. Use
  mexEvalString to evaluate the command in the caller
  workspace. Use the
  mexGetVariable and
  mexPutVariable functions
  to get and put variables into the caller workspace.
  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.
  mexEvalString |
  mexGetVariable |
  mexPutVariable |
  mwIndex |
  mwSize |
  mxArray