MATLAB Function Reference |
Write a Hierarchical Data Format (HDF) Version 5 file
Syntax
hdf5write(filename,location,dataset) hdf5write(filename,details,dataset) hdf5write(filename,details1,dataset1,details2,dataset2,...) hdf5write(filename,...,'WriteMode',mode,...)
Description
hdf5write(filename,location,dataset)
writes the data dataset
to the HDF5 file named filename
. If filename
does not exist, hdf5write
creates it. If filename
exists, hdf5write
overwrites the existing file, by default, but you can also append data to an existing file using an optional syntax.
location
defines where to write the data set in the file. HDF5 files are organized in a hierarchical structure similar to a UNIX directory structure. location
is a string that resembles a UNIX path.
hdf5write
maps the data in dataset
to HDF5 data types according to rules outlined below.
hdf5write(filename,details,dataset)
writes dataset
to filename
using the values in the details
structure. For a data set, the details
structure can contain the following fields.
Field Name |
Description |
Data Type |
Location |
Location of the data set in the file |
Character array |
Name |
Name to attach to the data set |
String |
hdf5write(filename,details,attribute)
writes the metadata attribute
to filename
using the values in the details
structure. For an attribute, the details
structure can contain following fields.
hdf5write(filename, details1, dataset1, details2, dataset2,...)
writes multiple data sets and associated attributes to filename
in one operation. Each data set and attribute must have an associated details
structure.
hdf5write(filename,...,'WriteMode',mode,...)
specifies whether hdf5write
overwrites the existing file (the default) or appends data sets and attributes to the file. Possible values for mode are 'overwrite'
and 'append'
.
Data Type Mappings
If the data being written to the file is composed of HDF5 objects, hdf5write
uses the same data type when writing to the file. For HDF5.h5enum
objects, the size and dimensions of the data set in the HDF5 file, called the dataspace in HDF5 terminology, is the same as the object's Data field.
If the data in the workspace that is being written to the file is a MATLAB data type, hdf5write
uses the following rules when translating MATLAB data into HDF5 data objects.
Examples
Write a 5-by-5 data set of uint8
values to the root group.
Write a 2-by-2 string data set in a subgroup.
dataset = {'north', 'south'; 'east', 'west'}; hdf5write('myfile2.h5', '/group1/dataset1.1', dataset);
Write a data set and attribute to an existing group.
dset = single(rand(10,10)); dset_details.Location = '/group1/dataset1.2'; dset_details.Name = 'Random'; attr = 'Some random data'; attr_details.AttachedTo = '/group1/dataset1.2'; attr_details.AttachType = 'dataset'; hdf5write('myfile2.h5', dset_details, dset, ... attr_details, attr, 'WriteMode', 'append');
Write a data set using objects.
See Also
hdf5read | hdfinfo |
© 1994-2005 The MathWorks, Inc.