Read data from HDF5 dataset


data =
data =,mem_type_id,mem_space_id,file_space_id,dxpl)


data = reads the entire dataset specified by dataset_id.

data =,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 ='example.h5'); 
dset_id =,'/g1/g1.1/dset1.1.1');
data =;

Read the 2x3 hyperslab starting in the 4th row and 5th column of the example dataset.

plist = 'H5P_DEFAULT';
fid ='example.h5'); 
dset_id =,'/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]);
data =,'H5ML_DEFAULT',mem_space_id,file_space_id,plist);
Was this topic helpful?