Hello, I have to transform a 63×132 (r,c) matrix from excel into a netcdf file, and wrote the following code,
year='2009';month='07';day={'12'; '13'; '14'; '15'; '16'; '17'};hour={'00'; '01'; '02'; '03'; '04'; '05'; '06'; '07'; '08'; '09'; '10'; '11'; '12'; '13'; '14'; '15'; '16'; '17'; '18'; '19'; '20'; '21'; '22'; '23'};for i = 1:6 for j = 1:24 Sheetname = strcat(year,month,day{i},hour{j},'00'); RAIN = xlsread('result2.xls',Sheetname); NetCdfName=strcat(year,month,day{i},hour{j},'.MPE.nc'); nccreate(NetCdfName,'RAINNC', 'Dimensions', {'time', 1, 'south_north', 63, 'west_east', 132}, 'Format', 'classic'); ncwrite(NetCdfName,'RAINNC',RAIN, eye(63,132)); endend
And I got the following error;
Error using netcdflibIndex argument is out of bounds.Error in netcdf.putVar (line 87)netcdflib(funcstr,ncid,varid,varargin{:});Error in internal.matlab.imagesci.nc/write (line 819) netcdf.putVar(gid,varid, start, count, varData);Error in ncwrite (line 76)ncObj.write(varName, varData, start, stride);Error in ex2cdf (line 17) ncwrite(NetCdfName,'RAINNC',RAIN, eye(63,132));
I couldn't find enough examples with nc functions, and tried to make my way with basic examples on documentation, but failed as you can see. Any help is much appreciated to create the file.
Thanks in advance.
Best Answer