H5 - How to create attribute within a group?

조회 수: 3 (최근 30일)
yonatan s
yonatan s 2019년 7월 4일
편집: yonatan s 2019년 7월 4일
EDIT: issue fixed- loc_id should be change to gid
Hello,
I am trying to create an attribute ('BoxSize') within a group ('Header') using H5 library.
my code generates the attribute outside the group.
I've tried to change HeaderAtt to "/Header/BoxSize" but it did not help.
I am using MATLAB R2018b.
thanks in advance.
fcpl = H5P.create('H5P_FILE_CREATE');
fapl = H5P.create('H5P_FILE_ACCESS');
fid = H5F.create('newfile.hdf5','H5F_ACC_TRUNC',fcpl,fapl);
plist = 'H5P_DEFAULT';
%create Groups
Group=["/Header";"PartType0";"/RuntimePars";"/Units"];
for i=1:numel(Group)
gid = H5G.create(fid,Group(i),plist,plist,plist);
end
HeaderAtt="BoxSize";
acpl_id = H5P.create('H5P_ATTRIBUTE_CREATE');
type_id = H5T.copy('H5T_NATIVE_DOUBLE');
space_id = H5S.create('H5S_SCALAR');
attr_id = H5A.create(fid,HeaderAtt,type_id,space_id,acpl_id);

답변 (0개)

태그

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by