Skip to Main Content Skip to Search
Product Documentation

netcdf.inqVarID - Return ID associated with variable name

Syntax

varid = netcdf.inqVarID(ncid,varname)

Description

varid = netcdf.inqVarID(ncid,varname) returns varid, the ID of a netCDF variable specified by the text string, varname.

ncid is a netCDF file identifier returned by netcdf.create or netcdf.open.

This function corresponds to the nc_inq_varid function in the netCDF library C API. To use this function, you should be familiar with the netCDF programming paradigm. See netcdf for more information.

Examples

This example opens the example netCDF file included with MATLAB, example.nc, and uses several inquiry functions to get the ID of the first variable.

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 

See Also

netcdf.create | netcdf.inqVar | netcdf.open

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS