MATLAB: Reading the name of a dataset using h5read

h5disph5readMATLAB

Hi,
I have multiple .datx files which are readable using h5read function. Each of my file has a different name for its dataset. I would like my program to output its name as variable.
In Matlab, if you use h5disp('example.h5','/g4/') you will get the following information
HDF5 example.h5
Group '/g4'
Dataset 'lat'
Size: 19
MaxSize: 19
Datatype: H5T_IEEE_F64LE (double)
My question is how can I output the name of the Dataset. i.e. 'lat'

Best Answer

hinf = h5info(filename);
Then, for example,
{hinf.Groups(4).Datasets.Name} %the 4 corresponds to /g4