netcdf.putAtt
写入 netCDF 属性
语法
netcdf.putAtt(ncid,varid,attrname,attrvalue)
netcdf.putAtt(ncid,varid,attrname,attrvalue,xtype)
说明
netcdf.putAtt(ncid,varid,attrname,attrvalue)
将名为 attrname
的属性及其值 attrvalue
写入 varid
指定的 netCDF 变量。要指定全局属性,可对 varid
使用 netcdf.getConstant('NC_GLOBAL')
。
ncid
是 netcdf.create
或 netcdf.open
返回的 NetCDF 文件标识符。
netcdf.putAtt(ncid,varid,attrname,attrvalue,xtype)
将 attrvalue
作为在 xtype
中指定的数据类型写入。将 xtype
的值指定为:
包含以下值之一的字符向量或字符串标量
xtype
的值MATLAB® 类 NC_DOUBLE
double
NC_FLOAT
single
NC_INT64
(仅限 NetCDF-4 文件)int64
NC_UINT64
(仅限 NetCDF-4 文件)uint64
NC_INT
int32
NC_UINT
(仅限 NetCDF-4 文件)uint32
NC_SHORT
int16
NC_USHORT
(仅限 NetCDF-4 文件)uint16
NC_BYTE
int8
NC_UBYTE
(仅限 NetCDF-4 文件)uint8
NC_CHAR
char
NC_STRING
(仅限 NetCDF-4 文件)string
netcdf.getConstant
函数返回的等效数值netcdf.defVlen
函数返回的数值类型标识符(用于对应于元胞数组的用户定义的NC_VLEN
类型的属性)
注意
不能使用 netcdf.putAtt
设置 NetCDF4 文件的 '_FillValue'
属性。使用 netcdf.defVarFill
函数设置变量的填充值。
netcdf.putAtt
函数对应于 NetCDF 库 C API 中的几个属性 I/O 函数。要使用此函数,应该熟悉 NetCDF 编程范式。