netcdf.inqAttName
Return name of netCDF attribute
Syntax
attname = netcdf.inqAttName(ncid,varid,attnum)
Description
attname = netcdf.inqAttName(ncid,varid,attnum)
returns attname
,
a character vector containing the name of an attribute.
ncid
is a netCDF file identifier returned
by netcdf.create
or netcdf.open
.
varid
is a numeric identifier of a variable in the file. If you want to get
the name of a global attribute in the file, use
netcdf.getConstant('NC_GLOBAL')
in place of varid
. attnum
is a zero-based numeric value specifying the attribute, with 0
indicating the first attribute, 1 the second attribute, and so
on.
This function corresponds to the nc_inq_attname
function in the netCDF
library C API. To use this function, you should be familiar with the netCDF programming
paradigm.
Examples
This example opens the example netCDF file included with MATLAB®, 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