Contents Previous Next Subchapters

Writing HDF Data
Syntax
h5write(
fileobject typeobject parentobject namematrix)
See Also: h5read , write , bwrite

Description
Writes a matrix to an HDF file. The argument file is a character row vector that specifies an HDF5 file. If file does not exist, it is created. The argument object type is a character row vector which must be either "dataset" or "attribute". If object type equals "dataset" then the given matrix is added to the HDF file as an HDF dataset. If object type equals "attribute" then matrix is added as an HDF attribute. The argument object parent is a character row vector that specifies the fully-qualified name of an object for storing matrix. If object parent does not exist, it is created as a new group. If object parent is a dataset, object type must equal "attribute". The argument object name is a character row vector specifying the name for the output matrix. The argument matrix is an character, integer, real, or double-precision valued matrix.

O-Matrix supports reading, writing, and creating HDF5 files. See the NCSA HDF 5 site for more information about HDF5, and a description of this file format.

Example
If the file h5write.h5 does not exist, and you enter
     h5write("h5write.h5","dataset","/","dmat", {[1d0, 2], [3, 4]})
     h5write("h5write.h5","dataset","/Integer Data","vector", seq(3) )
O-Matrix will create a new HDF file that contains four HDF objects: the root group "/", the dataset "dmat", the group "/Integer Data", and the dataset "/Integer Data/vector".

If you continue the example by entering
     h5write("h5write.h5","attribute","/Integer Data/vector","description", "My Data"  )
     h5write("h5write.h5","attribute","/","Number", 1)
O-Matrix will add two attributes to the h5write.h5 data file. The attribute "description" is attached to the dataset "/Integer Data/vector". The attribute "Number" is attached to the group "/".

You can enter the following commands to display the contents of h5write.h5
     h5read("h5write.h5", "/", "dmat")
     h5read("h5write.h5", "/Integer Data", "vector")
     h5read("h5write.h5", "/Integer Data/vector", "description")
     h5read("h5write.h5", "/", "Number")
and O-Matrix will respond
{
[ 1 , 2 ]
[ 3 , 4 ]
}

{
1
2
3
}

My Data