我们能用C语言读一个smoking.mat(数据集)吗?

时间:2015-03-01 05:55:22

标签: c matlab

我想用C读它的原因是:
我想创建一个mnrfit.c文件/函数来代替mnrfit.m
要查看" smoking.mat",它位于Matlab的安装目录下:
    C:\ Program Files \ MATLAB \ R2013a \ help \ toolbox \ stats \ examples"
如果有可能,请告诉我如何加载名为吸烟的数据集(我搜索过,但很多但找不到方法)?
有一次,我能够在C中读取/加载smoking.mat。我将数据集保存在链表中(自己制作)

1 个答案:

答案 0 :(得分:1)

C / C ++中有一个库:

  

mat.h

这里有你所有的操作。 (包括开启/加载功能)

#include <mat.h>

matClose (C and Fortran)    Close MAT-file
matDeleteVariable (C and Fortran)   Delete named mxArray from MAT-file
MATFile (C and Fortran) Type for a MAT-file
matGetDir (C and Fortran)   Get directory of mxArrays in MAT-file
matGetFp (C)    Get file pointer to MAT-file
matGetNextVariable (C and Fortran)  Read next mxArray from MAT-file
matGetNextVariableInfo (C and Fortran)  Load array header information only
matGetVariable (C and Fortran)  Read mxArray from MAT-files
matGetVariableInfo (C and Fortran)  Load array header information only
matOpen (C and Fortran) Open MAT-file
matPutVariable (C and Fortran)  Write mxArrays to MAT-files
matPutVariableAsGlobal (C and Fortran)

This blog contains good info: Matlab C Library Mat File Operations