Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

h5read

Read data from HDF5 data set

Syntax

data = h5read(filename,datasetname)
data = h5read(filename,datasetname,start,count)
data = h5read(filename,datasetname,start,count,stride)

Description

data = h5read(filename,datasetname) retrieves all of the data from the HDF5 data set datasetname in the file filename.

data = h5read(filename,datasetname,start,count) reads a subset of data from the data set datasetname. start is the one-based index of the first element to be read. count defines how many elements to read along each dimension. If a particular element of count is Inf, h5read reads data until the end of the corresponding dimension.

data = h5read(filename,datasetname,start,count,stride) reads a subset of data, where stride specifies the interelement spacing along each data set extent.

Input Arguments

filename

Character vector specifying the name of an HDF5 file.

datasetname

Character vector specifying the name of a data set in an HDF5 file.

start

Numeric index value specifying the place to start reading data in the dataset in an HDF5 file. Indices are 1-based.

count

Numeric value specifying the amount of data to read.

stride

Numeric value specifying the intervalue spacing during the read operation. For example, a spacing of 2 indicates reading every other value.

Output Arguments

data

Data read from the data set.

Examples

collapse all

Read an entire data set from the sample file, example.h5.

h5disp('example.h5','/g4/lat')
HDF5 example.h5 
Dataset 'lat' 
    Size:  19
    MaxSize:  19
    Datatype:   H5T_IEEE_F64LE (double)
    ChunkSize:  []
    Filters:  none
    FillValue:  0.000000
    Attributes:
        'units':  'degrees_north'
        'CLASS':  'DIMENSION_SCALE'
        'NAME':  'lat'
data = h5read('example.h5','/g4/lat')
data =

   -90
   -80
   -70
   -60
   -50
   -40
   -30
   -20
   -10
     0
    10
    20
    30
    40
    50
    60
    70
    80
    90

Read the first 5-by-3 subset of a data set.

h5disp('example.h5','/g4/world')
HDF5 example.h5 
Dataset 'world' 
    Size:  36x19
    MaxSize:  36x19
    Datatype:   H5T_IEEE_F64LE (double)
    ChunkSize:  []
    Filters:  none
    FillValue:  0.000000
data = h5read('example.h5','/g4/world',[1 1],[5 3])
data =

     0     0     0
     0     0     0
     0     0     0
     0     0     0
     0     0     0

Read a data set of references to other data sets.

h5disp('example.h5','/g3/reference')
HDF5 example.h5 
Dataset 'reference' 
    Size:  2
    MaxSize:  2
    Datatype:   H5T_REFERENCE
    ChunkSize:  []
    Filters:  none
    FillValue:  H5T_REFERENCE
data = h5read('example.h5','/g3/reference')
data =

  2×1 cell array

    [2×1 int32 ]
    [2×1 single]

Related Examples

Introduced in R2011a

Was this topic helpful?