Call your own C or C++ 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 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 or C++ programs, use the MATLAB API for C engine library functions.