Main Content

Identifier (H5I)

HDF5 object identifiers


Use the MATLAB® HDF5 identifier interface, H5I, to handle HDF5 identifiers and access information about them.

HDF5 identifiers uniquely identify common HDF5 resources, such as files, groups, datasets, dataspaces, attributes and properties. They are returned by the functions that create or open these resources and are passed to functions that operate on or with these resources. You must close an object identifier after it is processed.



Decrement reference count

refcount = H5I.dec_ref(objID) decrements the reference count of the object specified by objID and returns the new count.


File identifier for specified object

fileID = H5I.get_file_id(objID) returns the identifier of the file associated with the object specified by objID.


Name of object

name = H5I.get_name(objID) returns the name of the group, dataset, or datatype specified by objID. If no name is attached to the object, H5I.get_name returns an empty character vector.

name = H5I.get_name(objID,"TextEncoding",encoding) additionally specifies the text encoding to use to interpret the object name.



Reference count of object

refcount = H5I.get_ref(objID) returns the reference count of the object specified by objID.


Type of object

objtype = H5I.get_type(objID) returns the type of the object identified by objID.



Increment reference count of specified object

refcount = H5I.inc_ref(objID) increments the reference count of the object specified by objID and returns the new count.


Determine if specified identifier is valid

output = H5I.is_valid(objID) returns a positive value if the identifier objID is valid, and 0 if it is not.


expand all

fid ="example.h5");
gid =,"/g4");
fid2 = H5I.get_file_id(gid);
name = H5F.get_name(fid2);
fprintf("The filename is %s.\n",name);

Version History

Introduced before R2006a

expand all