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{:});
Best Answer