Main Content
matlab.io.hdf4.sd.setAttr
Namespace: matlab.io.hdf4.sd
Write attribute value
Syntax
setAttr(objID,name,value)
Description
setAttr(objID,name,value)
attaches an attribute to the object specified
by objID
. If objID
is the
SD interface identifier, then a global attribute is created. If
a data identifier is specified, then the attribute is attached
to the dataset. If a dimension identifier is specified, then the
attribute is attached to the dimension.
This function corresponds to the SDsetattr
function
in the HDF library C API.
Examples
Attach attributes to a file, a dataset, and to a dimension.
import matlab.io.hdf4.* sdID = sd.start('myfile.hdf','create'); sd.setAttr(sdID,'creation_date',datestr(now)); sdsID = sd.create(sdID,'temperature','double',[10 20]); sd.setAttr(sdsID,'long_name','Temperature in sunlight.'); dimID0 = sd.getDimID(sdsID,0); sd.setAttr(dimID0,'long_name','latitude'); sd.endAccess(sdsID); sd.close(sdID);