Main Content

netcdf.reDef

Put open netCDF file into define mode

Syntax

netcdf.reDef(ncid)

Description

netcdf.reDef(ncid) puts an open netCDF file into define mode so that dimensions, variables, and attributes can be added or renamed. Attributes can also be deleted in define mode. ncid is a valid NetCDF file ID, returned from a previous call to netcdf.open or netcdf.create.

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

Examples

% Create a netcdf classic file 
ncid = netcdf.create('myfile.nc','CLASSIC_MODEL');
dimid = netcdf.defDim(ncid,'lat',50);
netcdf.endDef(ncid);
netcdf.close(ncid);
% Open the netcdf classic file
ncid = netcdf.open('myfile.nc','NC_WRITE')
%Put file in define mode.
netcdf.reDef(ncid);
% Try to define a dimension again. Should succeed.
dimid = netcdf.defDim(ncid, 'lon', 50);