netcdf.inqVarID
返回与变量名相关联的 ID
语法
varid = netcdf.inqVarID(ncid,varname)
说明
varid = netcdf.inqVarID(ncid,varname) 返回与 varname 对应的 varid。varname 指定为字符向量或字符串标量。
ncid 是 netcdf.create 或 netcdf.open 返回的 netCDF 文件标识符。
此函数对应于 netCDF 库 C API 中的 nc_inq_varid 函数。要使用此函数,应该熟悉 netCDF 编程范式。
示例
本例打开 MATLAB® 随附的 netCDF 示例文件 example.nc 并使用几个查询函数获取第一个变量的 ID。
ncid = netcdf.open('example.nc','NC_NOWRITE');
% Get information about first variable in the file.
[varname, xtype, dimids, atts] = netcdf.inqVar(ncid,0);
% Get variable ID of the first variable, given its name
varid = netcdf.inqVarID(ncid,varname)
varid =
0