String length Change when writing Hdf5.h5strings
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
John
2012-4-26
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 HDF5 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!