netcdf.delAtt
删除 netCDF 属性
语法
netcdf.delAtt(ncid,varid,attName)
说明
netcdf.delAtt(ncid,varid,attName) 删除由 attName 标识的属性。以字符向量或字符串标量形式指定 attName。
ncid 是 netcdf.create 或 netcdf.open 返回的 netCDF 文件标识符。
varid 是标识该变量的数值。要删除全局属性,对 varid 使用 netcdf.getConstant('GLOBAL')。必须在定义模式下才能删除该属性。
此函数对应于 netCDF 库 C API 中的 nc_del_att 函数。要使用此函数,应该熟悉 netCDF 编程范式。
示例
本例打开 MATLAB® 中所含 netCDF 示例文件 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