netcdf.renameAtt
更改属性名称
语法
netcdf.renameAtt(ncid,varid,oldName,newName)
说明
netcdf.renameAtt(ncid,varid,oldName,newName)
将 oldName
中指定的属性名称更改为 newName
中指定的名称。
将 oldName
和 newName
指定为字符向量或字符串标量。
ncid
是 netcdf.create
或 netcdf.open
返回的 netCDF 文件标识符。
varid
标识该属性所关联的变量。要指定全局属性,可对 varid
使用 netcdf.getConstant('NC_GLOBAL')
。
此函数对应于 netCDF 库 C API 中的 nc_rename_att
函数。要使用此函数,应该熟悉 netCDF 编程范式。
示例
本例修改 MATLAB® 随附的 netCDF 示例文件 example.nc
的本地副本。
% Open netCDF file. ncid = netcdf.open('my_example.nc','NC_WRITE') % Get the ID of a variable the attribute is associated with. varID = netcdf.inqVarID(ncid,'avagadros_number') % Rename the attribute. netcdf.renameAtt(ncid,varID,'description','Description'); % Verify that the name changed. attname = netcdf.inqAttName(ncid,varID,0) attname = Description