41 lines
1.4 KiB
C++
41 lines
1.4 KiB
C++
/*********************************************************************************************
|
||
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 <string>
|
||
#include <mat.h>
|
||
#include <vector>
|
||
using namespace std;
|
||
|
||
#define STRING_BUF_SIZE 204800
|
||
typedef double T;
|
||
/*
|
||
注意参数的区别,读取时候直接传递文件路径名,写入的时候需要提供文件指针,
|
||
这是因为写入的时候可能一次性需要写入多个矩阵
|
||
*/
|
||
|
||
/* 读取字符串矩阵 */
|
||
bool ReadMtxString(const string& filePath, const string& mtxName, vector<string>& 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);
|
||
|
||
/* 读取结构体中的字符串数据 */
|
||
bool ReadChildString2D(const string& filePath, const string& parentName, const string& selfName, vector<vector<string> >& vvStr);
|
||
|
||
/* 读取结构体中的二维double矩阵(一维的cell,每个cell又有一层cell,每个cell是一维double数组)*/
|
||
bool ReadChildDouble2D(const string& filePath, const string& parentName, const string& selfName, vector<vector<double> >& vvDouble);
|
||
|
||
|
||
#endif |