writehdf5attribute

Writes data to an existing attibute at a given location.

Syntax

writehdf5attribute(filename, attributeName, data)

writehdf5attribute(filename, datasetPath, attributeName, data)

writehdf5attribute(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. 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 Limitation
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_write',logical_data)
      logical_data = false;
      writehdf5attribute('test.h5','logical_data_write',logical_data)
      
      number_data=99;
      createhdf5dataset('test.h5','/number_dataset_write',number_data)
      number_data=9;
      createhdf5attribute('test.h5','/number_dataset_write','number_data_attribute',number_data)
      number_data=199;
      writehdf5attribute('test.h5','/number_dataset_write','number_data_attribute',number_data)
      
      real_matrix_data = [1,2;3,4];
      createhdf5group('test.h5','/group8')
      createhdf5attribute('test.h5','/group8','matrix_data_attribute',real_matrix_data)
      real_matrix_data = [11,22;33,44];
      writehdf5attribute('test.h5','/group8','matrix_data_attribute',real_matrix_data)

Example 2

Create attribute with string.
string_data='string attribute';
createhdf5attribute('test.h5','string_data_write',string_data)
string_data='string attribute write';
writehdf5attribute('test.h5','string_data_write',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.