필터 지우기
필터 지우기

String length Change when writing Hdf5.h5strings

조회 수: 1 (최근 30일)
Sameh Ahmed
Sameh Ahmed 2012년 4월 24일
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'

답변 (1개)

John
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.

카테고리

Help CenterFile Exchange에서 HDF5에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by