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.

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

collapse all

Write to Entire Data Set

Write random values to a data set named DS1.

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

Display the contents of the file.

h5disp('myfile.h5')
HDF5 myfile.h5 
Group '/' 
    Dataset 'DS1' 
        Size:  10x20
        MaxSize:  10x20
        Datatype:   H5T_IEEE_F64LE (double)
        ChunkSize:  []
        Filters:  none
        FillValue:  0.000000

Write to Block of Data Set

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 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');
HDF5 myfile.h5 
Group '/' 
    Dataset 'DS3' 
        Size:  20x10
        MaxSize:  20xInf
        Datatype:   H5T_IEEE_F64LE (double)
        ChunkSize:  5x5
        Filters:  none
        FillValue:  0.000000

Related Examples

Limitations

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

More About

collapse 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.

Introduced in R2011a

Was this topic helpful?