MATLAB Compiler | ![]() ![]() |
Why Compile M-Files?
There are three main reasons to compile M-files:
Stand-Alone Applications and Libraries
You can create MATLAB applications that take advantage of the mathematical functions of MATLAB, yet do not require that the user owns MATLAB. Stand-alone applications are a convenient way to package the power of MATLAB and to distribute a customized application to your users.
You can develop an algorithm in MATLAB to perform specialized calculations and use the Compiler to create a C shared library (DLL on Windows) or a C++ static library. You can then integrate the algorithm into a C/C++ application. After you compile the C/C++ application, you can use the MATLAB algorithm to perform specialized calculations from your program.
Hiding Proprietary Algorithms
MATLAB M-files are ASCII text files that anyone can view and modify. MEX-files are binary files. Shipping MEX-files or stand-alone applications instead of M-files hides proprietary algorithms and prevents modification of your M-files.
Faster Execution
Compiled C or C++ code typically runs faster than its M-file equivalents because:
Cases When Performance Does Not Improve. Compilation is not likely to speed up M-file functions that:
Cases When Performance Does Improve. Compilation is most likely to speed up M-file functions that contain loops.
![]() | The MATLAB Compiler Family | Upgrading from Previous Versions | ![]() |