Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

Additional Information for Using MEX-Files

Files and Directories — UNIX Operating Systems

This section describes the directory organization and purpose of the files associated with the MATLAB C and Fortran API on UNIX[1] systems.

Figure: Directories where MATLAB C and Fortran API files are located on UNIX systems

matlabroot/bin

The matlabroot/bin directory contains two files that are relevant for the MATLAB API:

mex

UNIX shell script that creates binary MEX-files from C or Fortran MEX-file source code.

matlab

UNIX shell script that initializes your environment and then invokes the MATLAB interpreter.

This directory also contains the preconfigured options files that the mex script uses with particular compilers. For more information, see Specifying a UNIX Options File.

matlabroot/bin/$ARCH

The matlabroot/bin/$ARCH directory contains libraries, where $ARCH specifies a particular UNIX platform. On some UNIX platforms, this directory contains two versions of this library. Library file names ending with .so or .dylib are shared libraries.

matlabroot/extern/include

The matlabroot/extern/include directory contains the header files for developing C and C++ applications that interface with MATLAB.

The relevant header files for the MATLAB API are:

engine.h

C/C++ header file for MATLAB engine programs. Contains function prototypes for engine routines.

mat.h

C/C++ header file for programs accessing MAT-files. Contains function prototypes for mat routines.

matrix.h

C/C++ header file containing a definition of the mxArray structure and function prototypes for matrix access routines.

mex.h

Header file for building C/C++ MEX-files. Contains function prototypes for mex routines.

fintrf.h

Header file for building Fortran MEX-files. Contains function prototypes for mex routines.

matlabroot/extern/src

The matlabroot/extern/src directory contains those C source files that are necessary to support certain MEX-file features such as argument checking and versioning.

Files and Directories — Microsoft Windows Operating Systems

This section describes the directory organization and purpose of the files associated with the MATLAB C and Fortran API on Microsoft Windows systems.

The following figure illustrates the directories in which the MATLAB API files are located. In the illustration, matlabroot symbolizes the top-level directory where MATLAB is installed on your system.

Figure: Directories where MATLAB C and Fortran API files are located on Windows systems

matlabroot\bin

The matlabroot\bin directory contains the mex.bat batch file that builds C and Fortran files into binary MEX-files. Also, this directory contains mex.pl, which is a Perl script used by mex.bat.

matlabroot\bin\win32\mexopts or matlabroot\bin\win64\mexopts

The matlabroot\bin\win32\mexopts or matlabroot\bin\win64\mexopts directory contains the preconfigured options files that the mex script uses with particular compilers. For more information, see Specifying a Windows Options File.

matlabroot\extern\include

The matlabroot\extern\include directory contains the header files for developing C and C++ applications that interface with MATLAB.

The relevant header files for the MATLAB API (MEX-files, engine, and MAT-files) are

engine.h

C/C++ header file for MATLAB engine programs. Contains function prototypes for engine routines.

mat.h

C/C++ header file for programs accessing MAT-files. Contains function prototypes for mat routines.

matrix.h

C/C++ header file containing a definition of the mxArray structure and function prototypes for matrix access routines.

mex.h

Header file for building C/C++ MEX-files. Contains function prototypes for mex routines.

fintrf.h

Header file for building Fortran MEX-files. Contains function prototypes for mex routines.

*.def

Files used by Microsoft Visual C++ and Microsoft Fortran compilers.

matlabroot\extern\src

The matlabroot\extern\src directory contains files that are used for debugging MEX-files.

Examples

This book uses many examples to show how to write C and Fortran source MEX-files.

Examples from the Text

The refbook subdirectory in the extern/examples directory contains the MEX-file examples (C and Fortran) that are used in this topic.

MEX Reference Examples

The mex subdirectory of /extern/examples directory contains MEX-file examples. It includes the examples described in the online MATLAB C and Fortran API Reference for MEX-Files (the functions beginning with the mex prefix).

MX Examples

The mx subdirectory of extern/examples contains examples for using the array access functions. Although you can use these functions in standalone programs, most of these are MEX-file examples. The exception is mxSetAllocFcns.c, since this function is available only to standalone programs.

Engine and MAT Examples

The eng_mat subdirectory in the extern/examples directory contains the MEX-file examples (C and Fortran) for using the MATLAB engine facility, as well as examples for reading and writing MATLAB data files (MAT-files). These examples are all standalone programs.

Technical Support

The MathWorks provides additional Technical Support through its Web site. A few of the services provided are as follows:

This knowledge base, updated several times each week, on our Web site includes thousands of solutions and links to Technical Notes.

http://www.mathworks.com/support/

Our Technical Support staff writes technical notes to address commonly asked questions.

http://www.mathworks.com/support/tech-notes/list_all.html

[1] UNIX is a registered trademark of The Open Group in the United States and other countries.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS