This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Put open netCDF file into define mode




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 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. See netcdf for more information.


This example opens a local copy of the example netCDF file included with MATLAB®,

% Open a netCDF file.
ncid ='','NC_WRITE')

% Try to define a dimension. 
dimid = netcdf.defdim(ncid, 'lat', 50); % should fail.
??? Error using ==> netcdflib
NetCDF: Operation not allowed in data mode

Error in ==> defDim at 22
dimid = netcdflib('def_dim', ncid,dimname,dimlen);
% Put file in define mode.

% Try to define a dimension again. Should succeed.
dimid = netcdf.defDim(ncid, 'lat', 50);
Was this topic helpful?