Main Content

netcdf.inq

Return information about netCDF file

Syntax

[ndims,nvars,ngatts,unlimdimid] = netcdf.inq(ncid)

Description

[ndims,nvars,ngatts,unlimdimid] = netcdf.inq(ncid) returns the number of dimensions, variables, and global attributes in a netCDF file. The function also returns the ID of the dimension defined with unlimited length, if one exists.

ncid is a netCDF file identifier returned by netcdf.create or netcdf.open. You can call netcdf.inq in either define mode or data mode.

This function corresponds to the nc_inq function in the netCDF library C API. To use this function, you should be familiar with the netCDF programming paradigm.

Examples

This example opens the example netCDF file included with MATLAB®, example.nc, and uses the netcdf.inq function to get information about the contents of the file.

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

% Get information about the contents of the file.
[numdims, numvars, numglobalatts, unlimdimID] = netcdf.inq(ncid)

numdims =

     4


numvars =

     4


numglobalatts =

     1


unlimdimID =

     3