Reading Mat File In C

I am new to Visual Studio and C/C++ ...though i have worked in MATLAB ...

i am trying to load mat file using MAT API as given in MATLAB help but even for the simple code given below it is compiling but the solution is not building and its giving 4 errors all of same sort.. i have included all lib and header files as additional lib and include folders...

need serios help... thanks

Error 1 error LNK2019: unresolved external symbol _mxFree referenced in function _main test2.obj test2

Error 2 error LNK2019: unresolved external symbol _matGetVariable referenced in function _main test2.obj test2

the rest two errors are also of the other MAT-API...

enter code here

#include <mat.h>
#include <stdio.h>
void main()
{

MATFile *pmat;
const char **dir;
int     ndir;      
int     i;
mxArray *pfp;

pmat=matOpen("data3.mat","r");


 /* get directory of MAT-file */
 dir = (const char **)matGetDir(pmat, &ndir);


printf("Directory of %s:n","data3.mat");
for (i=0; i < ndir; i++)
{
    printf("%sn",dir[i]);
}   

//to get the pointer of data from file  
 pfp=matGetVariable(pmat, "fp");
 mxFree(dir);

 }  

It might help to look here

http://www.mathworks.com/help/techdoc/matlab_external/f19027.html


You need to link with the library provided with matlab. The linker settings are under project properties, Linker. There you have to set directories and additional inputs. As to where do you find the needed library - depends on your matlab installation. It's probably delivered with some demo programs, so look at their project settings.

链接地址: http://www.djcxy.com/p/65864.html

上一篇: Opencv 2.3.1的问题

下一篇: 在C中读取Mat文件