/********************************************************************************************* Description: 提供基本matlab读写数据功能 Copyright : All right reserved by ZheYuan.BJ Author : Zhang Zhonghai Date : 2023/09/18 adfasdf ***********************************************************************************************/ #ifndef __MATLAB_IO_H #define __MATLAB_IO_H #include #include #include using namespace std; #define STRING_BUF_SIZE 10240 typedef double T; /* 注意参数的区别,读取时候直接传递文件路径名,写入的时候需要提供文件指针, 这是因为写入的时候可能一次性需要写入多个矩阵 */ /* 读取字符串矩阵 */ bool ReadMtxString(const string& filePath, const string& mtxName, vector& vStr, int* pRowNum, int* pColNum); /* 从mat文件中读取给定名称的矩阵数据,并获取矩阵的行列数值 */ T* ReadMtxDouble(const string& filePath, const string& mtxName, int* pRowNum, int* pColNum); /* 将数据写入mat文件中,用给定的名称命名 */ bool SaveMtxDouble(T* src, MATFile* pMatFile, string matrixName, int rowNum, int colNum); #endif