MEX File Creation API

Build MATLAB® functions from C/C++ and Fortran functions

Call your own C, C++, or Fortran programs from the MATLAB command line as if they were built-in functions. These programs are called MEX files and the function name is the MEX file name.

Write your programs using the MATLAB API libraries — MEX Library and the C/C++ Matrix Library or Fortran Matrix Library. The functions in these libraries facilitate the transfer of data between MEX files and the workspace. Build the source file into an executable program using the mex function. You can also share the MEX file with other MATLAB users.

If you want to call MATLAB functions from C, C++, or Fortran programs, use the MATLAB Engine API for C, C++, and Fortran library functions.

Was this topic helpful?