Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

netcdf.defDim

Create netCDF dimension

Syntax

dimid = netcdf.defDim(ncid,dimname,dimlen)

Description

dimid = netcdf.defDim(ncid,dimname,dimlen) creates a new dimension in the netCDF file specified by ncid, wheredimname is a character string that specifies the name of the dimension and dimlen is a numeric value that specifies its length. To define an unlimited dimension, specify the predefined constant 'NC_UNLIMITED' for dimlen, using netcdf.getConstant to retrieve the value.

netcdf.defDim returns dimid, a numeric ID corresponding to the new dimension.

This function corresponds to the nc_def_dim 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.

For copyright information, read the netcdfcopyright.txt and mexnccopyright.txt files.

Examples

Create a new file and define two dimensions in the file. One dimension is an unlimited dimension. To run this example, you must have write permission in your current folder.

% Create a netCDF file.
ncid = netcdf.create('foo.nc','NC_NOCLOBBER')

% Define a dimension.
lat_dimID = netcdf.defDim(ncid,'latitude',360);

% Define an unlimited dimension.
long_dimID = netcdf.defDim(ncid,'longitude',...
		netcdf.getConstant('NC_UNLIMITED'));
Was this topic helpful?