Function File: ncwriteatt(filename,varname,attname,val)

Defines the attribute attname of the variable varname in the file filename with the value val.

Global attributes can be defined by using "/" or the group name as varname. The type of value is mapped to the NetCDF data types. (see ncinfo).

Example

Create a netcdf4 format file with a variable mydata and assign an attribute "units" to it.

nccreate("myfile.nc", "mydata", "Format", "netcdf4");
ncwriteatt("myfile.nc", "mydata", "Units", "K");

See also: ncinfo.

Package: netcdf