How can I write and read logical data types to my HDF5 data file in MATLAB 7.8 (R2009a)?
조회 수: 3 (최근 30일)
이전 댓글 표시
I am using HDF5 low-level functions to write data to an HDF5 file. I would like to save my MATLAB LOGICAL array to HDF5. I have tried using the following code:
fid = H5F.create('myhdf5.h5','H5F_ACC_TRUNC','H5P_DEFAULT','H5P_DEFAULT');
dspace = H5S.create_simple(1,10,10);
dset = H5D.create(fid,'BoolTest','H5T_NATIVE_HBOOL',dspace,'H5P_DEFAULT');
H5D.write(dset,'H5T_NATIVE_HBOOL','H5S_ALL','H5S_ALL','H5P_DEFAULT',rand(10,1));
H5D.close(dset);
H5S.close(dspace);
H5F.close(fid)
However this fails with the error:
??? Error using ==> hdf5lib2
Incorrect type of array passed
to H5D.write in conjunction with
the specified memory datatype.
Error in ==> H5D.write at 37
H5ML.hdf5lib2('H5Dwrite',
varargin{:});
채택된 답변
MathWorks Support Team
2009년 6월 27일
HDF5 1.8.x does not support a boolean datatype. To work around this, use an integer type and interpret your data according to your rules.
For more information see the HDF5 FAQ by doing an internet search for: "HDF5 faq boolean".
댓글 수: 0
추가 답변 (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!