How do I append new data to an existing variable in a NETCDF file ?
10 ビュー (過去 30 日間)
古いコメントを表示
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?
採用された回答
MathWorks Support Team
2009 年 8 月 14 日
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で NetCDF についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!