This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Introducing MEX Files

You can call your own C, C++, or Fortran subroutines from the MATLAB® command line as if they were built-in functions. These programs, called binary MEX files, are dynamically linked subroutines that the MATLAB interpreter loads and executes. The MEX file contains only one function or subroutine, and its name is the MEX file name. To call a MEX file, use the name of the file, without the file extension.

For information about using a MEX function that someone else created, see Call MEX File Functions.

The term mex stands for “MATLAB executable” and has different meanings, as shown in the following table.

MEX TermDefinition
source MEX fileC, C++, or Fortran source code file.
binary MEX file or MEX functionDynamically linked subroutine executed in the MATLAB environment.
MEX function libraryMATLAB C and Fortran API Reference library to perform operations in the MATLAB environment.
mex build scriptMATLAB function to create a binary file from a source file.

Related Examples

More About