Change name of attribute




netcdf.renameAtt(ncid,varid,oldName,newName) changes the name of the attribute specified by the character string oldName.

newName is a character string that specifies the new name.

ncid is a netCDF file identifier returned by netcdf.create or

varid identifies the variable to which the attribute is associated. To specify a global attribute, use netcdf.getConstant('NC_GLOBAL') for varid.

This function corresponds to the nc_rename_att function in the netCDF library C API. To use this function, you should be familiar with the netCDF programming paradigm. See netcdf for more information.


This example modifies a local copy of the example netCDF file included with MATLAB®,

% Open netCDF file.
ncid ='','NC_WRITE')

% Get the ID of a variable the attribute is associated with.
varID = netcdf.inqVarID(ncid,'avagadros_number')

% Rename the attribute.

% Verify that the name changed.
attname = netcdf.inqAttName(ncid,varID,0)

attname =

Was this topic helpful?