Main Content

netcdf.inqAtt

netCDF 属性に関する情報を返します。

構文

[xtype,attlen] = netcdf.inqAtt(ncid,varid,attname)

説明

[xtype,attlen] = netcdf.inqAtt(ncid,varid,attname) は、attname によって識別される属性のデータ型 xtype と長さ attlen を返します。attname は文字ベクトルまたは string スカラーとして指定します。

ncid は、関数 netcdf.create または関数 netcdf.open によって返される netCDF ファイル識別子です。

varid は属性が関連付けられている変数を識別します。グローバル属性に関する情報を取得するには、varid の代わりに netcdf.getConstant('NC_GLOBAL') を指定します。

この関数は、NetCDF ライブラリ C API の関数 nc_inq_att に相当します。この関数を使用するには、NetCDF プログラミング パラダイムに関する知識が必要です。

この例では、MATLAB® に含まれている netCDF サンプル ファイル 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