How do I read or understand this code?

4 visualizaciones (últimos 30 días)
Anonymous
Anonymous el 13 de Feb. de 2016
Comentada: Anonymous el 14 de Feb. de 2016
"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.

Respuesta aceptada

Brattv
Brattv el 13 de Feb. de 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 comentario
Anonymous
Anonymous el 14 de Feb. de 2016
Well explained Mr. Brattland. Thank you very much.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by