String length Change when writing Hdf5.h5strings
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
How to make sure that stings written to hdf5 file have a StringLength: variable?
When I write an array of hdf5.h5strings with variable length to file using hdf5write and then read it using hdf5read string length change to that of the longest string in the structure.
>> class(data2)
ans =
hdf5.h5string
>> data2(3)
hdf5.h5string:
Name: ''
Length: 6
Padding: 'nullterm'
Data: 'Sample'
>> hdf5write('myfile.h5', '/group1', data2);
>> readgroup1=hdf5read('myfile.h5','/group1');
>> readgroup1(3)
hdf5.h5string:
Name: ''
Length: 16 <======== should be 6.
Padding: 'nullterm'
Data: 'Sample'
0 commentaires
Réponses (1)
John
le 26 Avr 2012
Hi Sameh, HDF5WRITE only writes out fixed-length strings, as you have noticed. It's also been deprecated in favor of a new high-level function called H5WRITE, but it only supports simple numeric types because there are just too many permutations of HDF5 datatypes to try to cover with one function.
In order to create variable-length string datasets, I would suggest looking at the H5T package, as this will give you the flexibility you need. The HDF Group has posted example MATLAB codes on their website that may help you as well, please see http://www.hdfgroup.org/ftp/HDF5/examples/examples-by-api/api18-m.html and look for the variable string example at the bottom.
0 commentaires
Voir également
Catégories
En savoir plus sur HDF5 dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!