nc_varput

The nc_varput functions writes data values into a netCDF variable of an open netCDF file. The file must be in data mode.

r = nc_varput(ncid, varid, rvStart, rvCount, values)
r = nc_varput(ncid, varid, rvStart, rvCount, values, bCharAsByte)

Return Value

r is -1 in case an error occurred.

Parameters

ncid

Identifies the netCDF file.

varid

varid is the ID of a variable.

rvStart

rvStart is a vector of values specifying the multidimensional index of the corner of the hyperslab where the first of the data values will be read from. The size of start must be the same as the number of dimensions of the specified variable. The elements of start must correspond to the variable’s dimensions in order. The indices are relative to 0.

rvCount

rvCount is a vector of values specifying the multidimensional edge lengths from the corner of the hyperslab where the first of the data values will be read. To read a single value, for example, specify rvCount as [1,1,…,1]. The size of rcCount is the number of dimensions of the specified variable. The elements of rvCount correspond to the variable’s dimensions.

values

values is a vector or matrix of real values or a string.

bCharAsByte

If bCharAsByte is TRUE (1) characters are specified as byte values (data type = NC_CHAR). For other data type this parameter has no meaning. Default value is FALSE (0).

Example

ncid = nc_create("d:/test.nc");
dimid = nc_dimdef(ncid, "n", 8);
varid = nc_vardef(ncid, "channel", NC_FLOAT, dimid);
nc_endef(ncid);
rvData = [1,2,3,4,5,6,7,8];
nc_varput(ncid, varid, 0, len(rvData), rvData);
nc_close(ncid);

id-467872