Main Content

本页翻译不是最新的。点击此处可查看最新英文版本。

netcdf.inqVar

有关变量的信息

语法

[varname,xtype,dimids,natts] = netcdf.inqVar(ncid,varid)

说明

[varname,xtype,dimids,natts] = netcdf.inqVar(ncid,varid) 返回 varid 标识的变量信息。参数 ncidnetcdf.createnetcdf.open 返回的 netCDF 文件标识符。

输出参数 varname 是变量名称。xtype 是数据类型,dimids 是维度 ID,natts 是与变量关联的属性数目。维度 ID 从 0 开始。

此函数对应于 netCDF 库 C API 中的 nc_inq_var 函数。但由于 MATLAB® 使用 FORTRAN 样式的排序方式,维度 ID 的顺序与从 C API 中获取的顺序相反。要使用此函数,应该熟悉 netCDF 编程范式。

示例

打开 MATLAB 随附的 netCDF 示例文件 example.nc 并获取文件中某个变量的信息。

% Open the example netCDF file.
ncid = netcdf.open('example.nc','NC_NOWRITE');

% Get information about third variable in the file.
[varname, xtype, dimids, numatts] = netcdf.inqVar(ncid,2)

varname =

peaks


xtype =

     5


dimids =

     0     1


numatts =

     1     1