什么是MEX文件,通过help MEX,可以看到如下解释:
MEX compiles and links source files into a shared library called a
MEX-file, executable from within MATLAB.
通过MEX把源文件编译、链接成一个共享的库称之为MEX文件, 该文件可以在MATLAB中运行。
MEX文件在不同的平台下,具有如下的扩展名:
sol2, SunOS 5.x - .mexsol
hpux - .mexhpux
hp700 - .mexhp7
ibm_rs - .mexrs6
sgi - .mexsg
alpha - .mexaxp
glnx86 - .mexglx
Windows - .dll
使用:
MEX Compile MEX-function.
MEX [option1 ... optionN] sourcefile1 [... sourcefileN]
[objectfile1 ... objectfileN] [libraryfile1 ... libraryfileN]
其中的参数可以参考MATLAB的help。
例子:在command line下输入
mex 带路径的文件名.c
运行后就会在源文件所在的路径下生成相应的文件,在windows下为.dll
相关链接:如何在VC6.0中编译与调试MEX程序http://luzhenbo.88uu.com.cn/Matlab/VC_mex.htm
http://www.mvonline.com.cn/jszx/rgzn/2006-01-07/665.html