Writing time series data to a netCDF file from workspace
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a worspace variable containing time varying data of a parameter `p` obtained at different coordinate positions. The rows correspond to different coordinate positions of a grid and columns correspond to diferent time points. I would like to save this data in mat file to netCDF format. I've tried the following to write the workspace variable `time` following the examples provided here
header = ['x', 'y', 'z', '0.2s', '0.4s', '0.6s', '0.8s', '1.0s']
time = [0.2 0.4 0.6 0.8 1.0];
mydata = rand(10,8) %first 3 columns (x,y,z) coordinates next 5 time series data at 0.2,0.4,0.6,0.8,1 seconds
% define mode
ncid = netcdf.create('myfile.nc','CLOBBER');
dimid = netcdf.defDim(ncid,'my_dim',length(time))
varid = netcdf.defVar(ncid,'time','NC_BYTE',dimid)
netcdf.endDef(ncid)
% data mode
netcdf.putVar(ncid,varid,time)
netcdf.close(ncid)
% verify
ncid2 = netcdf.open('myfile.nc','NC_NOWRITE');
x = netcdf.getVar(ncid2,0);
whos x
netcdf.close(ncid2)
I'd like to ask for suggestions on how to write the rest of the data ( coordinates and time-varying data of `p` stored in `mydata`) in the same netcdf file.
1 Kommentar
Antworten (1)
Bhupendra Prajapati
am 17 Jul. 2020
You could create another netcdf file put write your data in that file and then merge it with your myfile.nc
Refer to the link below for instructions on merging.
https://www.mathworks.com/help/matlab/import_export/exporting-to-network-common-data-form-netcdf-files.html?s_tid=answers_rc2-3_p6_MLT#bsxb8lu-1
2 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!