【问题标题】:Reading Mat File In C在 C 中读取 Mat 文件
【发布时间】:2011-06-08 05:07:29
【问题描述】:

我是 Visual Studio 和 C/C++ 的新手……虽然我曾在 MATLAB 中工作过……

我正在尝试使用 MATLAB 帮助中给出的 MAT API 加载 mat 文件,但即使对于下面给出的简单代码,它也在编译,但解决方案没有构建,并且它给出了 4 个相同类型的错误。我已经包括了所有lib 和头文件作为附加的 lib 和包含文件夹...

需要 serios 帮助...谢谢

错误 1 ​​错误 LNK2019:未解析的外部符号 _mxFree 在函数 _main test2.obj test2 中引用

错误 2 错误 LNK2019:未解析的外部符号 _matGetVariable 在函数 _main test2.obj test2 中引用

其余两个错误也是其他 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("%s\n",dir[i]);
}   

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

 }  

【问题讨论】:

    标签: c matlab


    【解决方案1】:

    【讨论】:

      【解决方案2】:

      您需要链接到 matlab 提供的库。链接器设置位于项目属性 Linker 下。在那里你必须设置目录和额外的输入。至于您在哪里找到所需的库 - 取决于您的 matlab 安装。它可能与一些演示程序一起提供,因此请查看它们的项目设置。

      【讨论】:

      • 我之前也复制了所需的库,甚至尝试将 MATLAB 库的链接作为附加库提供...但是同样的错误...
      猜你喜欢
      • 2018-07-04
      • 2016-05-18
      • 2020-11-03
      • 1970-01-01
      • 2015-06-30
      • 1970-01-01
      相关资源
      最近更新 更多