I have downloaded era specific humidity data in .nc file.In that data specific humidity as a variable is present ant that is 4x3x4x9862 where 4=lon,3=lat,4=pressure level and 9862=time.Now I am creating a nc file where I want this in format 3x4x4x9862 where 3=lat,4=lon,4=pressure level and 9862=time. I have written a programme and create variable for nc file like that
nccreate('test_files.nc','q','Dimensions',{'lat' 3 'lon' 4 'lev' 4 'time' 9862 });
ncwrite('test2_files.nc','q',q(3,4,4,9862));
but
error Attempted to access q(3,4,4,9862); index out of bounds because
size(q)=[4,3,4,9862].
How can I solve the problem?

댓글 수: 6

per isakson
per isakson 2017년 8월 28일
It works here on R2016a. Note that the filename is not the same in the two lines of code.
Try:
nccreate('test2_files.nc','q','Dimensions',{'lat' 3 'lon' 4 'lev' 4 'time' 9862 });
ncwrite('test2_files.nc','q',q);
ncwrite('test_files.nc','q',Q1);
Error using netcdflib The NetCDF library encountered an error during execution of 'putVaraFloat' function - 'Start+count exceeds dimension bound (NC_EEDGE)'.
Error in netcdf.putVar (line 85) netcdflib(funcstr,ncid,varid,varargin{:});
Error in internal.matlab.imagesci.nc/write (line 824) netcdf.putVar(gid, varid,start, count, varData);
Error in ncwrite (line 76) ncObj.write(varName, varData, start, stride);
ncwrite('test2_files.nc','q',q(3,4,4,9862));
This is working fine in my version 2017.
I have worked on matlab2015.ncwrite('test2_files.nc','q',q(3,4,4,9862)); giving error message.
KSSV
KSSV 2017년 8월 30일
In that case..write a matrix in loop.....write q(:,:,:,i) at a loop i.

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Color and Styling에 대해 자세히 알아보기

태그

질문:

2017년 8월 28일

댓글:

2017년 8월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by