netcdf.getAtt
netCDF 属性を返す
構文
attrvalue = netcdf.getAtt(ncid,varid,attname)
attrvalue = netcdf.getAtt(ncid,varid,attname,output_type)
説明
attrvalue = netcdf.getAtt(ncid,varid,attname)
は、attname
で指定された名前の属性の値 attrvalue
を返します。attname
は string スカラーまたは文字ベクトルとして指定します。返される属性の値 attrvalue
は、attname
の netCDF データ型に最も適合する MATLAB® データ型の値です。MATLAB による最良の適合の判別方法の詳細については、詳細を参照してください。
attrvalue = netcdf.getAtt(ncid,varid,attname,output_type)
は、output_type
で指定された出力データ型を使用して attrvalue
を返します。output_type
は次の値のいずれかとして指定します。
"double"
"single"
"int64"
"uint64"
"int32"
"uint32"
"int16"
"uint16"
"int8"
"uint8"
"char"
この関数は、NetCDF ライブラリ C API のさまざまな属性の I/O 関数に相当します。この関数を使用するには、NetCDF プログラミング パラダイムに関する知識が必要です。
例
この例では、MATLAB に含まれている netCDF サンプル ファイル example.nc
を開き、最初の変数に関連付けられている属性の値を取得します。また、ファイルのグローバル変数の値を取得します。
% Open a NetCDF file. ncid = netcdf.open("example.nc","NC_NOWRITE"); % Get name of first variable. [varname vartype vardimIDs varatts] = netcdf.inqVar(ncid,0); % Get ID of variable, given its name. varid = netcdf.inqVarID(ncid,varname); % Get attribute name, given variable id. attname = netcdf.inqAttName(ncid,varid,0); % Get value of attribute. attval = netcdf.getAtt(ncid,varid,attname); % Get name of global attribute gattname = netcdf.inqAttName(ncid,netcdf.getConstant("NC_GLOBAL"),0); % Get value of global attribute. gattval = netcdf.getAtt(ncid,netcdf.getConstant("NC_GLOBAL"),gattname) gattval = 09-Jun-2008