Add MatlabWriter.
This commit is contained in:
21
src/MatlabWriter.cpp
Normal file
21
src/MatlabWriter.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "MatlabWriter.h"
|
||||
#include <matio.h>
|
||||
|
||||
MatlabWriter::MatlabWriter(const std::string& aFileName)
|
||||
: mFileName(aFileName)
|
||||
{
|
||||
mMat = Mat_CreateVer(mFileName.c_str(),nullptr, MAT_FT_MAT5);
|
||||
}
|
||||
|
||||
MatlabWriter::~MatlabWriter()
|
||||
{
|
||||
Mat_Close(mMat);
|
||||
}
|
||||
|
||||
void MatlabWriter::write(const Aurora::Matrix& aMatrixs, const std::string& aName)
|
||||
{
|
||||
size_t dims[2] ={(size_t)aMatrixs.getDimSize(0),(size_t)aMatrixs.getDimSize(1)};
|
||||
matvar_t* var = Mat_VarCreate(aName.c_str(),MAT_C_DOUBLE,MAT_T_DOUBLE,2,dims,aMatrixs.getData(),0);
|
||||
Mat_VarWrite(mMat,var,MAT_COMPRESSION_NONE);
|
||||
Mat_VarFree(var);
|
||||
}
|
||||
20
src/MatlabWriter.h
Normal file
20
src/MatlabWriter.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef MATLABWRITER_H
|
||||
#define MATLABWRITER_H
|
||||
|
||||
#include "Matrix.h"
|
||||
#include <vector>
|
||||
#include <matio.h>
|
||||
|
||||
class MatlabWriter
|
||||
{
|
||||
public:
|
||||
MatlabWriter(const std::string& aFileName);
|
||||
~MatlabWriter();
|
||||
void write(const Aurora::Matrix& aMatrixs, const std::string& aName);
|
||||
|
||||
private:
|
||||
std::string mFileName;
|
||||
mat_t* mMat;
|
||||
};
|
||||
|
||||
#endif // MATLABWRITER_H
|
||||
Reference in New Issue
Block a user