%% Display Dataset Attribute Names
% Open each attribute in a dataset and print their names.
% Open the dataset dset1.1.1 in the file example.h5.

fid = H5F.open('example.h5');
gid = H5G.open(fid,'/g1/g1.1');
dset_id = H5D.open(fid,'/g1/g1.1/dset1.1.1');
info = H5O.get_info(dset_id);

% Open each attribute, print its name, then close it.

for idx = 0:info.num_attrs-1

	attr_id =H5A.open_by_idx(gid,'dset1.1.1','H5_INDEX_NAME','H5_ITER_DEC',idx);
	fprintf('attribute name:  %s\n',H5A.get_name(attr_id));
	H5A.close(attr_id);
end
H5G.close(gid);
H5F.close(fid);

% Copyright 2021 The MathWorks, Inc.