C中使用MATLAB的mat文件
2009-11-01 13:26
162 查看
C中访问Matlab数据文件Mat的方式:
mat数据格式是matlab的数据存储的标准格式。
(1)首先将Mat.h所在的includes文件夹加到Vs2005的include配置中:
Tools-Options-Projects and Solutions-VC++ Directories
在show derectories for:中选择includes file
将Matlab安装目录下的extern/include添加到其中。
(2)#include<mat.h>
(3)常见函数:
matopen 打开mat文件
matclose 关闭mat文件
magetfp 取得mat文件的c语言句柄
matGetArray 取得一个数组
/*
* Open a MAT-file "filename" using mode "mode". Return
* a pointer to a MATFile for use with other MAT API functions.
*
* Current valid entries for "mode" are
* "r" == read only.
* "w" == write only (deletes any existing file with name <filename>).
* "w4" == as "w", but create a MATLAB 4.0 MAT-file.
* "w7.3" == as "w", but create a MATLAB 7.3 MAT-file.
* "u" == update. Read and write allowed, existing file is not deleted.
*
* Return NULL if an error occurs.
*/
EXTERN_C MATFile * matOpen(const char *filename, const char * mode);
/*
* Close a MAT-file opened with matOpen.
*
* Return zero for success, EOF on error.
*/
EXTERN_C int matClose(MATFile *pMF);
/*
* Write array value with the specified name to the MAT-file, deleting any
* previously existing variable with that name in the MAT-file.
*
* Return zero for success, nonzero for error.
*/
EXTERN_C int matPutVariable(
MATFile * pMF,
const char * name,
const mxArray * pA
);
/*
* Read the array value for the specified variable name from a MAT-file.
*
* Return NULL if an error occurs.
*/
EXTERN_C mxArray * matGetVariable(MATFile * pMF, const char * name);
mat数据格式是matlab的数据存储的标准格式。
(1)首先将Mat.h所在的includes文件夹加到Vs2005的include配置中:
Tools-Options-Projects and Solutions-VC++ Directories
在show derectories for:中选择includes file
将Matlab安装目录下的extern/include添加到其中。
(2)#include<mat.h>
(3)常见函数:
matopen 打开mat文件
matclose 关闭mat文件
magetfp 取得mat文件的c语言句柄
matGetArray 取得一个数组
/*
* Open a MAT-file "filename" using mode "mode". Return
* a pointer to a MATFile for use with other MAT API functions.
*
* Current valid entries for "mode" are
* "r" == read only.
* "w" == write only (deletes any existing file with name <filename>).
* "w4" == as "w", but create a MATLAB 4.0 MAT-file.
* "w7.3" == as "w", but create a MATLAB 7.3 MAT-file.
* "u" == update. Read and write allowed, existing file is not deleted.
*
* Return NULL if an error occurs.
*/
EXTERN_C MATFile * matOpen(const char *filename, const char * mode);
/*
* Close a MAT-file opened with matOpen.
*
* Return zero for success, EOF on error.
*/
EXTERN_C int matClose(MATFile *pMF);
/*
* Write array value with the specified name to the MAT-file, deleting any
* previously existing variable with that name in the MAT-file.
*
* Return zero for success, nonzero for error.
*/
EXTERN_C int matPutVariable(
MATFile * pMF,
const char * name,
const mxArray * pA
);
/*
* Read the array value for the specified variable name from a MAT-file.
*
* Return NULL if an error occurs.
*/
EXTERN_C mxArray * matGetVariable(MATFile * pMF, const char * name);
相关文章推荐
- [置顶] Matlab中save实现保存数据到mat文件的正确使用
- MATLAB中使用load动态载入mat文件
- 调试经验——使用Matlab绘制f(x)=sin(1/x)的函数图形
- 在Matlab中使用Levmar
- Matlab使用笔记-uint8类型之间的运算的坑
- 使用mex C生成MATLAB的股票数据分析接口
- Matlab中下标,斜体,及希腊字母的使用方法
- 使用Matlab 画 ROC需要哪些数据
- win10处理.mat文件遇到的问题+matlab激活
- 图像处理(Matlab)-再次学习如何使用Matlab
- 举例说明使用MATLAB Coder从MATLAB生成C/C++代码步骤
- matlaB中 libsvm的 使用
- 初步探索如何使用Visual C#调用Matlab
- MATLAB中%注释的使用方法
- 使用C#,Matlab(2015a)混合编程
- 使用DLT算法求解相机参数及相机与物体的位置关系(附加C/C++和Matlab代码)
- 接触Matlab10年后的一个总结,随时使用Matlab要掌握的一些要点
- MATLAB中使用Cell对M文件分节
- matlab中使用结构体
- matlab 条件删除某元胞元素时不能使用for,而应该使用while进行遍历所有元胞