nccreate
Create a variable in a netCDF file.
📝Syntax
nccreate(filename, varname, 'Dimensions', dimensions)
nccreate(filename, varname, 'Dimensions', dimensions, 'Datatype', datatype)
📥Input Arguments
Parameter Description
filename Path of the netCDF file to create or update.
varname Variable name to define in the file.
dimensions Cell array containing dimension name and length pairs, for example {'time', 3}.
datatype Optional Nelson datatype name such as 'double', 'single', 'int32', or 'char'.
📤Output Arguments
Parameter Description
none This function does not return a value.
📄Description

nccreate defines a variable and its dimensions in a local netCDF file. If the file does not exist, it is created.

Use name-value pairs to describe the variable schema before writing data with ncwrite.

💡Examples
Copy-paste example for nccreate.
filename = [tempdir(), 'help_nccreate.nc'];
nccreate(filename, 'temperature', 'Dimensions', {'x', 3});
info = ncinfo(filename);
info.Variables(1).Name
🔗See Also
ncwritencreadncinfo
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub