netcdf.open

Open NetCDF data source

Syntax

ncid = netcdf.open(source)
ncid = netcdf.open(source,mode)
[chosen_chunksize, ncid] = netcdf.open(source,mode,chunksize)

Description

ncid = netcdf.open(source) opens source, which can be the name of a NetCDF file or the URL of an OPeNDAP NetCDF data source, for read-only access. Returns a NetCDF ID in ncid.

ncid = netcdf.open(source,mode) opens source with the type of access specified by mode, which can have any of the following values.

Value Description
'WRITE'Read-write access
'SHARE'Synchronous file updates
'NOWRITE'Read-only access (Default)

You can also specify mode as a numeric value that can be retrieved using netcdf.getConstant. Use these numeric values when you want to specify a bitwise-OR of several modes.

[chosen_chunksize, ncid] = netcdf.open(source,mode,chunksize) opens source, an existing netCDF data source, specifying the additional I/O performance tuning parameter, chunksize. The actual value used by the NetCDF library might not correspond to the input value you specify.

This function corresponds to the nc_open and nc__open functions in the netCDF library C API. To use this function, you should be familiar with the netCDF programming paradigm. See netcdf for more information.

Examples

This example opens the example NetCDF file included with MATLAB®, example.nc.

ncid = netcdf.open('example.nc','NOWRITE');
netcdf.close(ncid);
Was this topic helpful?