H5 - How to create attribute within a group?
2 次查看(过去 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!