Main Content

netcdf.inqAttName

返回 netCDF 属性名称

语法

attname = netcdf.inqAttName(ncid,varid,attnum)

说明

attname = netcdf.inqAttName(ncid,varid,attnum) 返回包含属性名称的字符向量 attname

ncidnetcdf.createnetcdf.open 返回的 netCDF 文件标识符。

varid 是文件中变量的数值标识符。如果您想要获取文件中全局属性的名称,请使用 netcdf.getConstant('NC_GLOBAL') 替代 varidattnum 是一个从 0 开始的指定属性的数值,0 指示第一个属性,1 指示第二个属性,以此类推。

此函数对应于 netCDF 库 C API 中的 nc_inq_attname 函数。要使用此函数,应该熟悉 netCDF 编程范式。

示例

本例打开 MATLAB® 随附的 netCDF 示例文件 example.nc

% Open netCDF example file.
ncid = netcdf.open('example.nc','NC_NOWRITE');

% Get identifier of a variable in the file.
varid = netcdf.inqVarID(ncid,'avagadros_number')

% Get the name of the attribute associated with the variable.
attname = netcdf.inqAttName(ncid,varid,0)

attname =

description

% Get the name of the global attribute associated with the variable.
gattname = netcdf.inqAttName(ncid,netcdf.getConstant('NC_GLOBAL'),0)

gattname =

creation_date