Matlab R2014a由.m文件产生C代码,在VS2010中运行

1、首先,准备.m文件:mySub.m

function c = mySub(a,b)%#codegen
c = a - b;
end

其中,%#codegen可以防止出现警告错误

2、在matlab的命令行窗口输入mex -setup,回车,根据提示选择编译器:如果已安装VS2010,会自动配置为Microsoft Visual C++ 2010 (C),如需其他语言,可按需选择;

mex -setup
MEX 配置为使用 ‘Microsoft Visual C++ 2010 (C)’ 以进行 C 语言编译。
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:

你可能感兴趣的:(Matlab R2014a由.m文件产生C代码,在VS2010中运行)