Return netCDF dimension name and length


[dimname, dimlen] = netcdf.inqDim(ncid,dimid)


[dimname, dimlen] = netcdf.inqDim(ncid,dimid) returns the name, dimname, and length, dimlen, of the dimension specified by dimid. If ndims is the number of dimensions defined for a netCDF file, each dimension has an ID between 0 and ndims-1. For example, the dimension identifier of the first dimension is 0, the second dimension is 1, and so on.

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

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


The example opens the example netCDF file include with MATLAB®,

ncid ='','NC_NOWRITE');

% Get name and length of first dimension
[dimname, dimlen] = netcdf.inqDim(ncid,0)

dimname =


dimlen =