MATLAB: Am I unable to read MAT-files with the HDF5READ function, even when they are saved with the “-v7.3” flag

hdf5readhdf5writeMATLABrefernce

I have saved some data in an HDF-format MAT-file using the SAVE commands:
for i = 1:2
x(i).a= rand;
end
save('test.mat','x','-v7.3') ;
where "x" is a structure with a field "a" .
However, when I use high-level HDF5 functions to read this file, it fails. For instance, when executing
hdf5read('test.mat', '/x/a')
I receive the error:
??? Error using ==> hdf5readc
H5T_REFERENCE types cannot be read using hdf5read.
Similarly, HDF5READ fails even if HDF5INFO works fine.
For instance, when I execute the following:
hinfo = hdf5info('test.mat');
hdf5read(hinfo.GroupHierarchy.Groups(2).Datasets(1))
I receive the error:
??? Error using ==> hdf5readc
H5T_REFERENCE types cannot be read using hdf5read.
Error in ==> hdf5read at 88
[data, attributes] = hdf5readc(settings.filename, ...

Best Answer

This occurs because MATLAB's high-level HDF5 functions like HDF5READ do not support references. HDF5READ and HDF5INFO only work on files like those which are created by HDF5WRITE, which use nested structures in the file instead of references.