error using netcdf.putVar
显示 更早的评论
I don't see a difference when compared to the Matlab help, any idea?
MATLAB CODE
close all
clear all
nlon=180;
nlat=90;
filenc=['slope.nc']
ncid = netcdf.create(filenc,'NC_WRITE');
%creating dimensions
dimid_lon = netcdf.defDim(ncid,'longitude',nlon);
%creating variables and attributes
varid_lon = netcdf.defVar(ncid,'longitude','double',dimid_lon);
netcdf.putAtt(ncid,varid_lon,'long_name','Longitude')
netcdf.putAtt(ncid,varid_lon,'units','degrees_east')
lont=linspace(-180,180,nlon);
netcdf.putVar(ncid,varid_lon,lont);
netcdf.close(ncid)
this is the output:
Error using netcdflib
The NetCDF library encountered an error during execution of 'putVarDouble' function -
'Operation not allowed in define mode (NC_EINDEFINE)'.
Error in netcdf.putVar (line 87)
netcdflib(funcstr,ncid,varid,varargin{:});
Error in toMatlabHelp (line 15)
netcdf.putVar(ncid,varid_lon,lont);
采纳的回答
更多回答(1 个)
aditya deshmukh
2018-5-30
0 个投票
Hello, I tried all the above techniques to solve the error but still it persisted. I freed some space in the drive where these nc files were generated and yes, it worked!!!
1 个评论
mmYin
2018-10-18
Hi, I encountered the same problem and tried your solution. It still doesn’t work. Do you know why? thx a lot!
类别
在 帮助中心 和 File Exchange 中查找有关 NetCDF Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!