ncwrite error dimension does not have an associated length specified
Show older comments
Hi I got a problem to use ncwrite
Since I want to create a ncfile with lon(313), lat(409), time(3) and climate data. Example below
And got this error
Error using internal.matlab.imagesci.nc/createDimension
'longitude' does not have an associated length specified.
Error in internal.matlab.imagesci.nc/createDimensions (line 289)
this.createDimension(defgid, ...
Error in internal.matlab.imagesci.nc/createVariable (line 422)
this.createDimensions(groupName, dimensions);
Error in nccreate (line 170)
ncObj.createVariable(varName, varargin{:})
climate=rand(313,409,3);
lonn=rand(313,1);
latt=rand(409,1);
time=rand(3,1);
fileout='climate3.nc';
nccreate(fileout,'time','Dimensions',{'time',1,nz},'Datatype', 'double') ;
ncwrite(fileout,'time',time);
nccreate(fileout,'latitude','Dimensions',{'lat',1,ny},'Datatype', 'single')
ncwrite(fileout,'latitude',latt);
nccreate(fileout,'longitude','Dimensions',{'lon',1,nx},'Datatype', 'single');
ncwrite(fileout,'longitude',lonn);
nccreate(fileout,'climate','Dimensions',{'longitude','latitude','time'}) ;
ncwrite(fileout,'climate',climate) ;
Accepted Answer
More Answers (0)
Categories
Find more on Climate Science and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!