天天看點

vc++6.0讀寫MAT檔案

    這裡的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

vc++6.0讀寫MAT檔案

2>setting-Link-Input:

Additional library path:

%MATLAB%\extern\lib\win32\microsoft\msvc60

Object/library modules: