A MEX file is a function, created in MATLAB, that calls a C, C++, or Fortran subroutine. To call a MEX file, use the name of the file, without the file extension. The MEX file contains only one function or subroutine, and its name is the MEX file name. The file must be on your MATLAB path.
This example shows how to build the example
MEX files are subroutines created from C/C++ or Fortran source code. They behave just like MATLAB scripts and built-in functions.
Put your MEX file in a folder on the MATLAB path.
How to run a MEX file.
For best results, run MEX files built with your MATLAB version.
If you get a binary MEX file from another source, be sure that the file was compiled for the same platform on which you want to run it.
What to do when you get an invalid MEX file error.