| Contents | Index |
ncwriteschema(filename,schema)
ncwriteschema(filename,schema) creates or adds attributes, dimensions, variable definitions and group structure defined in schema to the file filename.
Use ncwriteschema in combination with ncinfo to create a new NetCDF file based on the schema of an existing file. You can also use ncwriteschema to add variable definitions, attributes, dimensions, or group structure to an existing file.
Note ncwriteschema does not write variable data. Use ncwrite to write data to the created variables. Created unlimited dimensions will have an initial size of 0 until you write data. |
Note ncwriteschema cannot change the format of an existing file. It cannot redefine existing variables and dimensions in filename. If your schema contains attributes, dimensions, variable definitions, or a group structure that already exist in the file, writeschema issues a warning but continues processing. |
Create a classic format file with two dimension definitions.
mySchema.Name = '/';
mySchema.Format = 'classic';
mySchema.Dimensions(1).Name = 'time';
mySchema.Dimensions(1).Length = Inf;
mySchema.Dimensions(2).Name = 'rows';
mySchema.Dimensions(2).Length = 10;
ncwriteschema('emptyFile.nc', mySchema);
ncdisp('emptyFile.nc');Create a netcdf4_classic format file to store a single variable from an existing file. First use ncinfo to get the schema of the peaks variable from the file. Then use ncwriteschema to create a NetCDF file, defining the peaks variable. Use ncread to get the data associated with the peaks variable and then use ncwrite to write the data to the variable in the new NetCDF file.
myVarSchema = ncinfo('example.nc','peaks');
ncwriteschema('peaksFile.nc',myVarSchema);
peaksData = ncread('example.nc','peaks');
ncwrite('peaksFile.nc','peaks',peaksData);
ncdisp('peaksFile.nc');ncdisp | ncinfo | ncread | ncwrite | netcdf

Explore how to use MATLAB to make advancements in engineering and science.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |