Main Content

matlab.io.hdfeos.gd.writeAttr

Package: matlab.io.hdfeos.gd

Write grid attribute

Syntax

writeAttr(gridID,attrname,data)

Description

writeAttr(gridID,attrname,data) writes an attribute to a grid. If the attribute does not exist, it is created. If the attribute exists, it can be modified in place, but it cannot be recreated with a different data type or length.

This function corresponds to the GDwriteattr function in the HDF-EOS library C API.

Examples

import matlab.io.hdfeos.*
srcFile = fullfile(matlabroot,'toolbox','matlab','imagesci','grid.hdf');
copyfile(srcFile,'myfile.hdf');
fileattrib('myfile.hdf','+w');
gfid = gd.open('myfile.hdf','rdwr');
gridID = gd.attach(gfid,'PolarGrid');
gd.writeAttr(gridID,'modification_date',datestr(now));
gd.detach(gridID);
gd.close(gfid);

See Also