MATLAB Compiler    

Creating MEX-Files

The MATLAB Compiler, when invoked with the -x macro option, produces a MEX-file from M-files. The Compiler

  1. Translates your M code to C code.
  2. Generates a MEX wrapper.
  3. Invokes the mex utility which builds the C MEX-file source into a MEX-file by linking the MEX-file with the MEX version of the math libraries (libmatlbmx).

Figure 1-1, Developing MEX-Files, illustrates the process of producing a MEX-file. The MATLAB interpreter dynamically loads MEX-files as they are needed.

Figure 1-1: Developing MEX-Files

MATLAB users who do not have the MATLAB Compiler must write the source code for MEX-files in either Fortran or C. External Interfaces/API in the MATLAB documentation explains the fundamentals of this process. To write MEX-files, you have to know how MATLAB represents its supported data types and the MATLAB external interface (i.e., the application program interface, or API.)

If you are comfortable writing M-files and have the MATLAB Compiler, then you do not have to learn all the details involved in writing MEX-file source code.


  Uses of the Compiler Creating Stand-Alone Applications