Data not written correctly to netcdf file
이전 댓글 표시
Hello,
I am trying to create a netcdf file with variables 'latitude', 'longitude' and 'zeros' to create a map of the world. I want to create a 0.5 degree grid so my latitude and longitude vectors have lengths of 360 and 720, respectively. My code (below) runs fine but when it creates the variable 'zeros' it does not write any data (i.e. has a cell value of 9.9692100e+36) for rows 714 (columns 246-360) and 715-720 (all columns). This produces a stripe going across my map when I visualise the data. Do you have any idea why this might be happening?
ncid = netcdf.create('Annual.nc','NC_NOCLOBBER');
%Define dimensions
londimid = netcdf.defDim(ncid,'lon', 720);
latdimid = netcdf.defDim(ncid,'lat', 360);
%Define variables
latvarid=netcdf.defVar(ncid, 'lat', 'float', latdimid);
lonvarid=netcdf.defVar(ncid, 'lon', 'float', londimid);
zerosvarid=netcdf.defVar(ncid, 'zeros', 'float', [latdimid londimid]);
netcdf.endDef(ncid)
%Write data to variables
netcdf.putVar(ncid,lonvarid,longitude);
netcdf.putVar(ncid,latvarid,latitude);
netcdf.putVar(ncid, zerosvarid, zeros(360,720));
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 NetCDF Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!