netcdf.inqAtt
Return information about netCDF attribute
Syntax
[xtype,attlen] = netcdf.inqAtt(ncid,varid,attname)
Description
[xtype,attlen] = netcdf.inqAtt(ncid,varid,attname)
returns the data type,
xtype
, and length, attlen
, of the attribute
identified in attname
. Specify attname
as a
character vector or string scalar.
ncid
is a netCDF file identifier returned
by netcdf.create
or netcdf.open
.
varid
identifies the variable that the attribute
is associated with. To get information about a global attribute, specify netcdf.getConstant('NC_GLOBAL')
in
place of varid
.
This function corresponds to the nc_inq_att
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
,
and gets information about an attribute in the file.
% Open netCDF example file. ncid = netcdf.open("example.nc","NOWRITE"); % Get identifier of a variable in the file, given its name. varid = netcdf.inqVarID(ncid,"avagadros_number"); % Get attribute name, given variable id and attribute number. attname = netcdf.inqAttName(ncid,varid,0); % Get information about the attribute. [xtype,attlen] = netcdf.inqAtt(ncid,varid,"description") xtype = 2 attlen = 31 % Get name of global attribute gattname = netcdf.inqAttName(ncid,netcdf.getConstant("NC_GLOBAL"),0); % Get information about global attribute. [gxtype gattlen] = netcdf.inqAtt(ncid, ... netcdf.getConstant("NC_GLOBAL"), ... gattname) gxtype = 2 gattlen = 11