Возврат информации об атрибуте netCDF
[xtype,attlen] = netcdf.inqAtt(ncid,varid,attname)
[xtype,attlen] = netcdf.inqAtt(ncid,varid,attname) возвращает тип данных, xtypeи длина, attlen, атрибута, указанного в attname. Определить attname в виде вектора символов или строкового скаляра.
ncid - идентификатор файла netCDF, возвращенный netcdf.create или netcdf.open.
varid определяет переменную, с которой связан атрибут. Чтобы получить информацию о глобальном атрибуте, укажите netcdf.getConstant('NC_GLOBAL') вместо varid.
Эта функция соответствует nc_inq_att в API библиотеки C netCDF. Для использования этой функции необходимо ознакомиться с парадигмой программирования netCDF.
В этом примере открывается пример файла netCDF, входящего в состав MATLAB ® ,example.ncи получает информацию об атрибуте в файле.
% 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