Read data from HDF5 dataset
data = H5D.read(dataset_id)
data = H5D.read(dataset_id,mem_type_id,mem_space_id,file_space_id,dxpl)
data = H5D.read(dataset_id)
reads the entire
dataset specified by dataset_id
.
data = H5D.read(dataset_id,mem_type_id,mem_space_id,file_space_id,dxpl)
reads
the dataset specified by dataset_id
. The mem_type_id
input
specifies the memory data type and should usually be 'H5ML_DEFAULT'
to
allow MATLAB® to determine the appropriate value. mem_space_id
describes
how the data is to be arranged in memory and should usually be 'H5S_ALL'
.
The file_space_id
input describes how the data
is to be selected from the file. It also can be given as 'H5S_ALL'
,
but this results in the entire dataset being read into memory. dxpl
is
the dataset transfer property list identifier and should usually be 'H5P_DEFAULT'
.
Note: The HDF5 library uses C-style ordering for multidimensional arrays, while MATLAB uses FORTRAN-style ordering. Please consult "Using the MATLAB Low-Level HDF5 Functions" in the MATLAB documentation for more information. |
Read an entire dataset.
fid = H5F.open('example.h5'); dset_id = H5D.open(fid,'/g1/g1.1/dset1.1.1'); data = H5D.read(dset_id); H5D.close(dset_id); H5F.close(fid);
Read the 2x3 hyperslab starting in the 4th row and 5th column of the example dataset.
plist = 'H5P_DEFAULT'; fid = H5F.open('example.h5'); dset_id = H5D.open(fid,'/g1/g1.1/dset1.1.1'); dims = fliplr([2 3]); mem_space_id = H5S.create_simple(2,dims,[]); file_space_id = H5D.get_space(dset_id); offset = fliplr([3 4]); block = fliplr([2 3]); H5S.select_hyperslab(file_space_id,'H5S_SELECT_SET',offset,[],[],block); data = H5D.read(dset_id,'H5ML_DEFAULT',mem_space_id,file_space_id,plist); H5D.close(dset_id); H5F.close(fid);