h5write

Write to HDF5 data set

Syntax

h5write(filename,datasetname,data)
h5write(filename,datasetname,data,start,count)
h5write(filename,datasetname,data,start,count,stride)

Description

h5write(filename,datasetname,data) writes data to an entire data set, datasetname, in the HDF5 file, filename.

h5write(filename,datasetname,data,start,count) writes a subset of the data to a data set, datasetname, in the HDF5 file, filename. start is a one-based index value that specifies the first element to be written. count specifies the number of elements to write along each dimension. h5write extends an extendable data set along any unlimited dimensions, if necessary.

h5write(filename,datasetname,data,start,count,stride) writes a hyperslab of data, where stride specifies the inter-element spacing along each dimension.

Input Arguments

filename

Text string specifying the name of an HDF5 file.

datasetname

Text string specifying the name of a data set in the HDF5 file.

data

Data to be written to the HDF5 file. You can specify only floating-point and integer data sets.

start

Numeric index value specifying where in the data set to start writing to the file.

count

Numeric value specifying how much data to write to the file.

stride

Numeric value specifying the interelement spacing of data to write to the file.

Default: Vector of ones.

Examples

Write to an entire data set.

h5create('myfile.h5','/DS1',[10 20]);
mydata = rand(10,20);
h5write('myfile.h5', '/DS1', mydata);

Write a hyperslab of data to the last 5-by-7 block of a data set.

 h5create('myfile.h5','/DS2',[10 20]);
        mydata = rand(5,7);
        h5write('myfile.h5','/DS2',mydata,[6 14],[5 7]);

Append data to an unlimited data set.

h5create('myfile.h5','/DS3',[20 Inf],'ChunkSize',[5 5]);
for j = 1:10
      data = j*ones(20,1);
      start = [1 j];
      count = [20 1];
      h5write('myfile.h5','/DS3',data,start,count);
end
h5disp('myfile.h5');

Limitations

  • h5write supports only floating point and integer data sets. To write to string data sets, you must use the H5D package.

More About

expand all

Hyperslab

A hyperslab is a collection of points in a data space. The points can be contiguous or form a regular pattern of points or blocks in a data space.

Was this topic helpful?