This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Return name of netCDF attribute


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


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

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 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. See netcdf for more information.


This example opens the example netCDF file included with MATLAB®,

% Open netCDF example file.
ncid ='','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 =


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

gattname =

Was this topic helpful?