MATLAB: How to make the HDF5READ and HDF5INFO functions in MATLAB 7.6 (R2008a) compatible with the code written in earlier versions of MATLAB

compatibilityhdf5infohdf5readMATLAB

I have used HDF5READ and HDF5INFO functions in earlier versions of MATLAB, prior to MATLAB 7.2 (R2006a).
hinfo = hdf5info('example.h5');
dset = hdf5read( hinfo.GroupHierarchy.Groups(2).Datasets(1));
Now I am using MATLAB R2008a and the HDF5READ and HDF5INFO function do not work correctly.

Best Answer

There has been a change made to the HDF5READ and HDF5INFO functions in MATLAB 7.2 (R2006a). To make your older code compatible with the newer version of MATLAB call the HDF5READ and HDF5INFO functions with the 'V71Dimensions' option set to true. If 'V71Dimensions' is set to true, HDF5READ (HDF5INFO) permutes the first two dimensions of the data set as it did in earlier releases of MATLAB. This behavior was intended to account for the difference in how HDF5 and MATLAB express array dimensions. HDF5 describes data set dimensions in row-major order; MATLAB stores data in column-major order. However, permuting these dimensions may not correctly reflect the intent of the data and may invalidate metadata. When 'V71Dimensions' is false (the default), the data dimensions correctly reflect the data ordering as it is written in the file --- each dimension in the output variable matches the same dimension in the file.
Consider the following example:
hinfo = hdf5info('example.h5');
dset = hdf5read( hinfo.GroupHierarchy.Groups(2).Datasets(1),'V71Dimensions', true);
The documentation for HDF5READ and HDF5INFO functions can be accessed by executing the following in your MATLAB prompt:
doc hdf5read
doc hdf5info