How can I write a struct data into h5 file?

66 vues (au cours des 30 derniers jours)
Xiao Jin
Xiao Jin le 13 Déc 2019
Hello everyone,
I have opened a .h5 file with MATLAB and want to change a dataset, which datatype ist H5T_COMPOUND (struct). I have written a new struct data (same struct, just one field's value changed), do you know how to write it into h5 file? Thank you!
Best Regards
Xiao

Réponses (4)

Isaac Li
Isaac Li le 9 Fév 2022
I adapted the code from https://support.hdfgroup.org/HDF5/examples/api18-m.html and created a file exchange function struct2hdf5 for everyone to use: https://www.mathworks.com/matlabcentral/fileexchange/106470-struct2hdf5

Sahithi Kanumarlapudi
Sahithi Kanumarlapudi le 16 Déc 2019
hdf5write' can be used to write data to a file in ‘.h5’ format.
For more information on how to use ‘hdf5write’ refer to the following link
  1 commentaire
per isakson
per isakson le 20 Déc 2019
Why recommend hdf5write rather than h5write ?

Connectez-vous pour commenter.


per isakson
per isakson le 20 Déc 2019
Modifié(e) : per isakson le 21 Déc 2019
If the Matlab support of HDF5 has not been updated in the most recent years there is no high level support for writing compound data to h5-files.
I found only this in the File Exchange Edit_struct_hdf5 by Renato Medeiros. It might be useful to you.
It can be done with the low level HFD5 functions, but I find it a bit tricky, YMMV. Did you study the low level Matlab samples at https://support.hdfgroup.org/HDF5/examples/api18-m.html, especially
  • Read / Write Compound Datatypes (Dataset) h5ex_t_cmpd.m and
  • Read / Write Compound Datatypes (Attribute) h5ex_t_cmpdatt.m

Xiao Jin
Xiao Jin le 16 Jan 2020
I solved the problem. Thanks for you help!
  1 commentaire
Richard Curry
Richard Curry le 6 Avr 2020
Could you tell us how you solved the problem pleasse? I'm having the same issue.

Connectez-vous pour commenter.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by