Возвратите информацию об атрибуте 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 функция в библиотеке C API 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