Section 8.9 External Language Interface
MATLAB provides several ways to integrate with other programming languages. For example, it is possible to integrate C (or C++) code into your MATLAB application. For details on how to accomplish this consult the MATLAB documentation:
One way to provide such integration is a Matlab Executable File (MEX-File). This is a function, created in MATLAB, that calls a C/C++ program and behaves just like a MATLAB script or function.
MEX files are native C or C++ files that are dynamically linked directly into the MATLAB application at runtime. They must be compiled for each hardware architecture on which they are to be run. MEX files have the potential to crash the MATLAB application, but rather large speed gains are possible, depending on the algorithm.