Search code examples
c++matlabhdf5matfile-conversion

How to read mat file in C++ without help of MATLAB API


I have a mat file with nested struct. I have attached an image for a better understanding.

enter image description here

I try the following procedure:
1. Convert the mat file to hdf5 format. (Using any language)
2. Read the hdf5 file in C++.

But the problem is I can not able to convert the mat file to hdf5. Is there any way to convert .mat file to .hdf5 file or read the mat file in C++ without help of MATLAB API?

Matlab version: R2018b
Windows version: Windows 10 64 bit

Solution

  • If you save your data in MATLAB using the -v7.3 flag, the MAT-file will be a HDF5 file. See the documentation:

    Version 7.3 MAT-files use an HDF5 based format that requires some overhead storage to describe the contents of the file. For cell arrays, structure arrays, or other containers that can store heterogeneous data types, Version 7.3 MAT-files are sometimes larger than Version 7 MAT-files.

    save filename CALIBRATION -v7.3