How to change the type when creating HDF5 attributes.
10 views (last 30 days)
Show older comments
Hi all,
I want to create attributes for a HDF5 file like this which is read from HDFView:
and here is my Matlab code:
h5writeatt('tt.h5','/tide','Dimension', "XY");
h5writeatt('tt.h5','/tide','Discretization', [2.0 3.0]);
h5writeatt('tt.h5','/tide','Origin', [-1.0 -1.0]);
h5writeatt('tt.h5','/tide','Max Buffer Size', int32(4));
h5writeatt('tt.h5','/tide','Cell Centered', "TRUE");
h5writeatt('tt.h5','/tide','Time Units', "d");
then I read it in HDFView, and the result is:
How shoud I change the type when creating the attributes? And the type of "Transient" is like BOOL, how shoud I set this type?
Thanks,
Peter
2 Comments
Les Beckham
on 1 Apr 2022
Edited: Les Beckham
on 1 Apr 2022
If I read your question correctly you are primarily concerned with the type of the "Transient" attribute, but you didn't show the code you used to write that attribute. What was the type of the data you wrote to that attribute? Was it logical or a string or a number?
Answers (1)
Les Beckham
on 1 Apr 2022
Edited: Les Beckham
on 1 Apr 2022
I don't have any hd5 files to test this with, but I suspect that if you change this
h5writeatt('tt.h5','/tide','Transient', "TRUE");
to this
h5writeatt('tt.h5','/tide','Transient', true);
you may achieve what you want.
"TRUE" is not a boolean (logical) value, it is a string.
4 Comments
Les Beckham
on 1 Apr 2022
You are welcome. Sorry it didn't help.
Good luck.
If your Matlab is under maintenance, you might want to contact Mathworks support to see if they can help. There is a "Contact Support" link at the bottom of this page.
See Also
Categories
Find more on HDF5 in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!