这里的MAT文件是指通过matlab save/load命令产生的数据文件。本文目的是在vc++6.0中使用Matlab导出的mat API接口对MAT数据文件经行操作。
程序源码可以参考帮助文档:External Interface/Importing and Exporting data/Examples of MAT-Files/Create a Mat-File in C
Matlab帮助文档提供的编译方式如下:
For example, to compile and link the stand-alone MAT application matcreat.c using MSVC Version 7.1 on Windows, first copy the file $MATLAB\extern\examples\eng_mat\matcreat.c
(where $MATLAB is the MATLAB root directory) to a directory that is writeable, and then use the following command to build it: mex -f $MATLAB\bin\win32\mexopts\msvc71engmatopts.bat matcreat.c
即用mcc编译。并没有提供调试的方法,于是我琢磨着用vc++6编译同样的.c文件。帮助文档:External Interface/Importing and Exporting data/Compiling and Linking MAT-File Programs/Required Files From Third-Party Sources提到了用第三方工具编译时需要的库。最终在baidu和文档的帮助下总结出如下设置,即可在VC++6中编译/调试:
创建工程,对工程进行如下设置:
1>setting-c/c++-PreProcessor:
Additional include dirctories:
%MATLAB%\extern\include
2>setting-Link-Input:
Additional library path:
%MATLAB%\extern\lib\win32\microsoft\msvc60
Object/library modules: