matio使用

时间:2021-09-03 07:48:11

http://na-wiki.csc.kth.se/mediawiki/index.php/MatIO

(1)build根据教程

(2)sudo ldconfig

(3)写main根据链接;修改几个类型错误

int main(void)
{ //const double a[5] = {43.5, 5432.434, 3.32, 0.0001, 88834.0};
double a[5] = {43.5, 5432.434, 3.32, 0.0001, 88834.0}; mat_t *mat;
matvar_t *matvar;
//int dims[2] = {1,5};
size_t dims[2] = {1,5}; mat = Mat_Open("simple.mat",MAT_ACC_RDWR); if(mat)
{
matvar = Mat_VarCreate("vec1",MAT_C_DOUBLE,MAT_T_DOUBLE,2,dims,a,0);
Mat_VarWrite( mat, matvar, MAT_COMPRESSION_NONE); Mat_VarFree(matvar);
Mat_Close(mat);
}
else
return 1; return 0;
}

(4)在caffe的makefile中加上

LIBRARIES += glog gflags protobuf boost_system m hdf5_hl hdf5
LIBRARIES += matio