Function File: ncwrite (filename, varname, x)
Function File: ncwrite (filename, varname, x, start, stride)

Write array x to the the variable varname in the NetCDF file filename.

The variable with the name varname and the appropriate dimension must already exist in the NetCDF file.

If start and stride are present, a subset of the variable is written. The parameter start contains the starting indices (1-based) and stride the increment between two successive elements. These parameters are vectors whose length is equal to the number of dimension of the variable.

If the variable has the _FillValue attribute, then the values equal to NaN are replaced by corresponding fill value NetCDF attributes scale_factor (default 1) and add_oddset (default 0) are use the transform the variable during writing:

x_in_file = (x - add_offset)/scale_factor

Example

Create a netcdf file with a variable of ’mydata’ and then write data to that variable.

nccreate('myfile.nc','mydata');
ncwrite('myfile.nc','mydata', 101);

See also: ncread,nccreate.

Package: netcdf