createhdf5attribute

Creates a new attibute at a given location and writes data to the attribute.

Syntax

createhdf5attribute(filename, attributeName, data)

createhdf5attribute(filename, datasetPath, attributeName, data)

createhdf5attribute(filename, groupPath, attributeName, data)

Inputs

filename
Path to the HDF5 file.
Type: string
datasetPath/groupPath
Optional. Fully qualified path of the dataset/group in the file. The file is considered as the location if this parameter is not provided.
Type: string
data
Data to write.
Type: logical | num | string | matrix | ndmatrix
Table 1. Data Type Mapping: Output Cell Contains the Following OML Data Types.
OML Variable Type HDF Data Type Limitations
Logical Integer
Number/Matrix/ND matrix Float Complex data is not supported.
String String Creates variable length strings.
Struct Not supported.
Cell/ND Cell Not supported.

Example 1

Create attribute with logical/number/matrix.
logical_data = true;
      createhdf5attribute('test.h5','logical_data',logical_data)
      
      number_data=99;
      createhdf5dataset('test.h5','/number_dataset',number_data)
      number_data=9;
      createhdf5attribute('test.h5','/number_dataset','number_data_attribute',number_data)
      
      real_matrix_data = [1,2;3,4];
      createhdf5group('test.h5','/group7')
      createhdf5attribute('test.h5','/group7','matrix_data_attribute',real_matrix_data)

Example 2

Create attribute with strings.
string_data='string attribute';
createhdf5attribute('test.h5','string_data',string_data)

Comments

Known limitations include:
  • Only logical, number, string, real matrix, and real ndmatrix are supported.
  • Complex data is not supported.
  • Compound data is not supported.