Change default netCDF file format


oldFormat = netcdf.setDefaultFormat(newFormat)


oldFormat = netcdf.setDefaultFormat(newFormat) changes the default format used by netCDF.create when creating new netCDF files, and returns the value of the old format. You can use this function to change the format used by a netCDF file without having to change the creation mode flag used in each call to netCDF.create. This setting persists for the remainder of the MATLAB® session or until you issue the command clear mex.

newFormat can be one of these values.

'NC_FORMAT_CLASSIC'Classic format — Original NetCDF format, used by all NetCDF files created between 1989 and 2004.

Classic format, 64–bit — Original format with 64–bit addressing capability to allow creation and access of much larger files.

'NC_FORMAT_NETCDF4'Enhanced model, HDF5-based — Introduced in 2008, NetCDF, version 4, extends the classic model and is based on HDF5.
'NC_FORMAT_NETCDF4_CLASSIC'Classic model, HDF5-based — Introduced in 2008, NetCDF, version 4, implements classic model but is based on HDF5.

You can also specify the numeric equivalent of these values, as retrieved by netcdf.getConstant.

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


oldFormat = netcdf.setDefaultFormat('NC_FORMAT_64BIT');