This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Using MEX Files

Binary MEX files are subroutines produced from C/C++ or Fortran source code. They behave just like MATLAB® scripts and built-in functions. To call a MEX file, use the name of the file, without the file extension. The calling syntax depends on the input and output arguments defined by the MEX file.

To experiment with calling MEX files, use the code in Table of MEX File Source Code Files to build and run examples.

While scripts have a platform-independent extension .m, MATLAB identifies MEX files by platform-specific extensions. The following table lists the platform-specific extensions for MEX files.

MEX File Platform-Dependent Extension

PlatformBinary MEX File Extension

Linux® (64-bit)


Apple Mac (64-bit)


Windows® (64-bit)


You cannot use a binary MEX file on a platform if you compiled it on a different platform. Recompile the source code on the platform for which you want to use the MEX file. For information about using MEX S-functions, see your Simulink® documentation.

Was this topic helpful?