How can I write and read logical data types to my HDF5 data file in MATLAB 7.8 (R2009a)?

4 ビュー (過去 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
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 件)

カテゴリ

Help Center および File ExchangeHDF5 についてさらに検索

製品


リリース

R2009a

Community Treasure Hunt

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

Start Hunting!

Translated by