H5 - How to create attribute within a group?
조회 수: 3 (최근 30일)
이전 댓글 표시
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
답변 (0개)
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!