netcdf.delAtt
Delete netCDF attribute
Syntax
netcdf.delAtt(ncid,varid,attName)
Description
netcdf.delAtt(ncid,varid,attName)
deletes the attribute identified by
attName
. Specify attName
as a character vector or
string scalar.
ncid
is a netCDF file identifier returned
by netcdf.create
or netcdf.open
.
varid
is a numeric value that identifies
the variable. To delete a global attribute, use netcdf.getConstant('GLOBAL')
for
the varid
. You must be in define mode to delete
an attribute.
This function corresponds to the nc_del_att
function in the netCDF library
C API. To use this function, you should be familiar with the netCDF programming
paradigm.
Examples
This example opens a local copy of the example netCDF file included
with MATLAB®, example.nc
.
% Open a netCDF file. ncid = netcdf.open('my_example.nc','NC_WRITE') % Determine number of global attributes in file. [numdims numvars numatts unlimdimID] = netcdf.inq(ncid); numatts = 1 % Get name of attribute; it is needed for deletion. attname = netcdf.inqAttName(ncid,netcdf.getConstant('NC_GLOBAL'),0) % Put file in define mode to delete an attribute. netcdf.reDef(ncid); % Delete the global attribute in the netCDF file. netcdf.delAtt(ncid,netcdf.getConstant('GLOBAL'),attname); % Verify that the global attribute was deleted. [numdims numvars numatts unlimdimID] = netcdf.inq(ncid); numatts = 0