User`s guide
1 Introducing the MATLAB Compiler
1-14
Why Compile M-Files?
There a re three main reasons to compile M-files:
•To create stand-alone applications or C shared libraries (DLLs on Windows)
or C++ static libraries
•To hide proprietary algorithms
•To speed them up
Stand-Alone Applications and Libraries
YoucancreateMATLAB applications that takeadvantageofthe 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
andusetheCompilertocreateaCsharedlibrary(DLLonWindows)oraC++
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 b inary files. Shipping MEX-files or stand-alone applications
instead of M-files hides propr ietary algorithms and prevents modification of
your M-files.
Faster Execution
Compiled C or C++ code typically runs faster than its M-file equivalents
because:
•Compiled code usually runs faster than interpreted code.
•C or C++ can avoid unnecessary memory allocation overhead that the
MATLAB interpreter performs.