1.新建 *.m文件
内容:
function c=Add(a,b)
c=a+b;
end
保存为 Add.m
2.命令行输入
>> mex -setup
MEX configured to use ‘Microsoft Visual C++ 2013 Professional (C)’ for C language compilation.
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. In the near future
you will be required to update your code to utilize the
new API. You can find more information about this at:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.
To choose a different language, select one from the following:
mex -setup C++
mex -setup FORTRAN
MEX configured to use ‘Microsoft Visual C++ 2013 Professional’ for C++ language compilation.
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. In the near future
you will be required to update your code to utilize the
new API. You can find more information about this at:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.
>> mbuild -setup
MBUILD configured to use ‘Microsoft Visual C++ 2013 Professional (C)’ for C language compilation.
To choose a different language, select one from the following:
mex -setup C++ -client MBUILD
mex -setup FORTRAN -client MBUILD
MBUILD configured to use ‘Microsoft Visual C++ 2013 Professional’ for C++ language compilation.
>> mcc -W cpplib:mydllAdd -T link:lib Add.m
使用 ‘Microsoft Visual C++ 2013 Professional’ 编译。
使用 ‘Microsoft Visual C++ 2013 Professional’ 编译。
3.结果如下:
注意:本人用matlab2014a没有成功,据说是因问没有完全破解,故重新下的2015b版本
下载安装链接:
http://jingyan.baidu.com/article/eae07827a466a31fed548563.html