netcdf.getConstant
返回命名常量的数值
语法
val = netcdf.getConstant(param_name)
说明
val = netcdf.getConstant(param_name)
返回对应 netCDF 库定义的常量名的数值。例如,netcdf.getConstant('NC_NOCLOBBER')
返回与 netCDF 常量 NC_NOCLOBBER
相对应的数值。
param_name
值可以是大写或小写,而且不需要波包含三个前导字符 'NC_'
。要检索 netCDF 库定义的所有名称列表,请使用 netcdf.getConstantNames
函数。
该函数在 netCDF C 接口中没有直接与其等同的函数。
示例
本例打开 MATLAB® 随附的 netCDF 示例文件 example.nc
。
% Open example file. ncid = netcdf.open('example.nc','NC_NOWRITE'); % Determine contents of the file. [ndims nvars natts dimm] = netcdf.inq(ncid); % Get name of global attribute. % Note: You must use netcdf.getConstant to specify NC_GLOBAL. attname = netcdf.inqattname(ncid,netcdf.getConstant('NC_GLOBAL'),0) attname = creation_date