Documentation

This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

h5writeatt

Write HDF5 attribute

Syntax

h5writeatt(filename,location,attname,attvalue)

Description

h5writeatt(filename,location,attname,attvalue) writes the attribute named attname with the value attvalue to the HDF5 file filename. The parent object location can be either a group or variable. location is the complete path name of the group or variable to which you want to associate the attribute.

Input Arguments

filename

Character vector specifying the name of an HDF5 file.

location

Character vector specifying the full path identifying a group or variable in an HDF5 file.

attname

Character vector specifying the name of an attribute in an HDF5 file. If the attribute does not exist, h5writeatt creates the attribute with the name specified.

If the specified attribute already exists but does not have a datatype or dataspace consistent with attvalue, h5writeatt deletes the attribute and recreates it. String attributes are created with a scalar dataspace.

attvalue

Value to be written to the attribute in an HDF5 file.

Examples

Create a root group attribute whose value is the current time.

srcFile = fullfile(matlabroot,'toolbox','matlab','demos','example.h5');
copyfile(srcFile,'myfile.h5');
fileattrib('myfile.h5','+w');
h5writeatt('myfile.h5','/','creation_date',datestr(now));

Create a double-precision data set attribute.

srcFile = fullfile(matlabroot,'toolbox','matlab','demos','example.h5');
copyfile(srcFile,'myfile.h5');
fileattrib('myfile.h5','+w');
attData = [0 1 2 3];
h5writeatt('myfile.h5','/g4/world','attr',attData);
h5disp('myfile.h5','/g4/world');

Related Examples

Introduced in R2011a

Was this topic helpful?