tbeu / matio

MATLAB MAT File I/O Library
https://matio.sourceforge.io
BSD 2-Clause "Simplified" License
330 stars 97 forks source link

How to append data to a mat file? #203

Closed Awelots closed 1 year ago

Awelots commented 1 year ago

I have written the structure to mat file, now I want to append the data to the structure, I know that I can use Mat_VarWriteAppend, and this function only supports MAT 7.3, but the MAT 7.3 file I created cannot be opened correctly in matlab. I hope you can tell me why I cannot create MAT 7.3 file or tell me other ways to add data. Thank you very much.

johnnyleeRH commented 1 year ago

same requirement, use Mat_VarWriteAppend not work well, use Mat_VarWriteData always return 13, this api not support now. I also need a example to show the use of Mat_VarWriteAppend, I need partially write mat files from a three-dims large matrix.

Awelots commented 1 year ago

same requirement, use Mat_VarWriteAppend not work well, use Mat_VarWriteData always return 13, this api not support now. I also need a example to show the use of Mat_VarWriteAppend, I need partially write mat files from a three-dims large matrix.

I had also try these two functions many times before I gave them up in disappointment,now I've chosen a temporary solution,use Mat_VarWrite,I don't write them until wait all my data arrive because they aren't many of them.

for three-dims, I've written a three-dims array in this way. size_t dims[3] = {3, 15, 4}; matvar_t *mat_vis = Mat_VarCreate("vis", MAT_C_SINGLE, MAT_T_SINGLE, 3, dims, float_array, 0); // float _array is a three-dims array and the number 3 means use the first three digits of the array dims Mat_VarWrite(mat, mat_vis, MAT_COMPRESSION_NONE);

Hope to help you, bro.

tbeu commented 1 year ago

I successfully run the tests of mat73_writeappend.at, also with reading the created files in MATLAB.

Awelots commented 1 year ago

I successfully run the tests of mat73_writeappend.at, also with reading the created files in MATLAB.

Thank you for your answer.

tbeu commented 1 year ago

Mat_VarWriteData

Mat_VarWriteData is deprecated and should not be used.

johnnyleeRH commented 1 year ago

I have tried test_write_2d_numeric test,if dim_append input is 1 or 2, the result file is not recognized in matlab.

tbeu commented 1 year ago

I tested again using matio v1.5.23, hdf5 v1.13.3, MATLAB R2023a on Ubuntu 22.04 and am not able to reproduce.