Using MEX-Files to Call C/C++ and Fortran Programs
From ift
Understanding MEX
MEX-files (MATLAB executables) are used to call large pre-existing C/C++ and Fortran programs from MATLAB without translating them into MATLAB. Another advantage is that C/C++ code is generally faster than MATLAB.
The best source of information is MathWorks' knowledge database.
To understand C/C++ Source MEX-Files see:
- Source MEX-Files (last checked 10 Jan 2011)
To understand how to use MEX-Files to Call C/C++ and Fortran Programs see
Tips 'n' Tricks
- Where to place the gateway routine within the C/C++ program - it looks like the gateway routine should be the last routine in the code. This sheds the problem with undefined variables and alike. I (GG) haven't found any place in the knowledge base where this is mentioned. Maybe it is not true in all cases either. Here follows an example that is a modification of the original MATLAB code from the knowledge database (see link "MEX-Files to Call C/C++ and Fortran Programs" above). In the case below three input parameters are required, while in the original code only two are necessary. A comparison between the two version helps to find the in-s and out-s.
