How do I read or understand this code?

"hinfo.GroupHierarchy.Groups(1,3).Groups(1,1).Groups(1,2).Groups,2"
Where,
  • hinfo = hdf5info(dateiname);
  • dateiname = [dateirumpf '.H5'];
  • dateirumpf is a character string.

 Réponse acceptée

Brattv
Brattv le 13 Fév 2016
It is pretty much just a way to get information from the fields. Lets do an example. I will first make a hdf file
hinfo = hdf5info('example.h5')
This results in
hinfo =
Filename: 'example.h5'
LibVersion: '1.8.12'
Offset: 0
FileSize: 35072
GroupHierarchy: [1x1 struct]
The first part of the code i calling the "GroupHierarchy" field
hinfo.GroupHierarchy
Which returns
Filename: 'D:\Program Files (x86)\Matlab\toolbox\matlab\demos\example.h5'
Name: '/'
Groups: [1x4 struct]
Datasets: []
Datatypes: []
Links: []
Attributes: [1x2 struct]
The next part of the code is calling the Groups field with the location (1,3). This seems to return the whole row of field 3
From the command window
Filename: 'D:\Program Files (x86)\Matlab\toolbox\matlab\demos\example.h5'
Name: '/g3'
Groups: []
Datasets: [1x32 struct]
Datatypes: []
Links: []
Attributes: []
As you see, the "Group" field is empty in this case and there is no reason to call it. But we are able to call Datasets
hinfo.GroupHierarchy.Groups(1,3).Datasets(1,1)
Which returns
Filename: 'D:\Program Files (x86)\Matlab\toolbox\matlab\demos\example.h5'
Name: '/g3/VLstring'
Rank: 1
Datatype: [1x1 struct]
Dims: 2
MaxDims: 2
Layout: 'contiguous'
Attributes: []
Links: []
Chunksize: []
FillValue: ''
Hope this helped. I would also like to tell you that Matlab recommends that you use H5INFO instead of hdf5info.

1 commentaire

Anonymous
Anonymous le 14 Fév 2016
Well explained Mr. Brattland. Thank you very much.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur App Building dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by