.. highlightlang:: us .. _nc_varput: nc_varput ========= .. index:: nc_varput .. us.tag nc_varput ENGLISH NC_Var The :ref:`nc_varput` functions writes data values into a netCDF variable of an open netCDF file. The file must be in data mode. .. function:: r = nc_varput(ncid, varid, rvStart, rvCount, values) r = nc_varput(ncid, varid, rvStart, rvCount, values, bCharAsByte) .. us.return **Return Value** *r* is -1 in case an error occurred. .. us.params **Parameters** .. uparam:: ncid Identifies the netCDF file. .. uparam:: varid *varid* is the ID of a variable. .. uparam:: 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. .. uparam:: 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. .. uparam:: values *values* is a vector or matrix of real values or a string. .. uparam:: 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). .. us.example **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); .. seealso:: :ref:`overview-netcdf-files`, :ref:`nc_create`, :ref:`nc_dimdef`, :ref:`nc_vardef`, :ref:`nc_endef`, :ref:`nc_redef`, :ref:`nc_close`, :ref:`nc_varget`, :ref:`nc_varput_missing`, :ref:`nc_varput_text`, :ref:`strcode` :sub:`id-467872`