필터 지우기
필터 지우기

How does one create a NetCDF file?

조회 수: 2 (최근 30일)
Louise Delaigue
Louise Delaigue 2017년 8월 3일
댓글: Chad Greene 2017년 8월 3일
Hi there!
I am desperately trying to create a NetCDF file that would include latitude, longitude and depth, to use as a bathymetry file in Ocean Data View. Here is the script that I came up with:
my_data = [lat lon depth]';
ncid = netcdf.create('sagbathy','NOCLOBBER');
dimid = netcdf.defDim(ncid,'my_dim',size(my_data));
varid = netcdf.defVar(ncid,'my_var','NC_BYTE',dimid);
netcdf.endDef(ncid);
netcdf.putVar(ncid,varid,my_data);
netcdf.close(ncid);
For some reason, the output ends up being a single number.
Could someone help me write the appropriate script?
Thank you so much!
Louise

답변 (1개)

Chad Greene
Chad Greene 2017년 8월 3일
Have you tried ncwrite? The process for writing netcdf files is described here.
  댓글 수: 2
Louise Delaigue
Louise Delaigue 2017년 8월 3일
The script that I 'wrote' uses this page but I think I must be getting something wrong somewhere. I'm new to Matlab so I don't understand every line just yet!
Chad Greene
Chad Greene 2017년 8월 3일
You're right, the procedure for writing NetCDFs is rather convoluted and unintuitive, so it's hard to diagnose the problem. I wish I could offer more help!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 NetCDF에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by