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.

Fortran MEX File Applications

Write Fortran subroutines that work with MATLAB®

You can call your own Fortran subroutines from the MATLAB command line as if they were built-in functions. These programs are called MEX files and the function name is the MEX file name.

To create a MEX file, write your programs using the MATLAB API libraries — Fortran MEX API and Fortran Matrix API. The functions in these libraries facilitate the transfer of data between MEX files and the workspace. For more information, see Fortran Source MEX Files. Then build the source file into an executable program using the mex function. For more information, see Executable Fortran MEX Files.

If you have a Fortran program and want to call MATLAB functions, then use the MATLAB Engine API for Fortran engine library functions.

If you want to read and write MATLAB data from Fortran programs, then use the MATLAB Fortran API to Read MAT-File Data.

For information about C/C++ programming APIs, see MATLAB API for C and MATLAB API for C++.