How do I append new data to an existing variable in a NETCDF file ?
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I need to append some data to an existing variable in a netcdf file (.nc file). Say, if I have created a netcdf file as follows,
% Create a 50 element vector for a variable.
my_vardata = linspace(0,50,50);
% Open netCDF file.
ncid = netcdf.create('foo.nc','NC_WRITE')
% Define the dimensions of the variable.
dimid = netcdf.defDim(ncid,'my_dim',50);
% Define a new variable in the file.
my_varID = netcdf.defVar(ncid,'my_var','double',dimid)
% Leave define mode and enter data mode to write data.
netcdf.endDef(ncid)
% Write data to variable.
netcdf.putVar(ncid,my_varID,my_vardata);
Now I want to open the file and append the some new data, say new_data=(51:100) to my_vardata in the file. How can I achieve this?
Respuesta aceptada
MathWorks Support Team
el 14 de Ag. de 2009
It is possible to append new data to an existing variable in a netcdf file. To make this possible, the dimension of the variable must be defined as NC_UNLIMITED. This is demonstrated using the attached MATLAB file "appendnewdata.m".
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre NetCDF en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!