To create a MEX file:
Install a MATLAB®-supported compiler. For more information, see Supported and Compatible Compilers.
Assemble your functions and the MATLAB API functions into one or more C/C++ or Fortran source files.
Write a gateway function in one of your source files.
Use the MATLAB
mex command, called a build script, to build a binary MEX
Use your binary MEX file like any MATLAB function.
If you have multiple compilers installed on your system, see Change Default Compiler.