- 积分
 - 205
 
	- 贡献
 -  
 
	- 精华
 
	- 在线时间
 -  小时
 
	- 注册时间
 - 2018-6-24
 
	- 最后登录
 - 1970-1-1
 
 
 
 
 
 
 | 
	
 
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册 
 
 
 
x
 
小白一个,想要把matlab中.mat格式的模式数据输出成dat文件或者nc文件在GRADS里绘图处理,输出的数组是2.5分辨率144*49的降水场,通过论坛学习了写dat文件和nc文件的代码如下: 
dat: 
fid=fopen('H:\data\prh.dat','w'); 
for j=1:49 
    for i=1:144 
        count=fwrite(fid,prh_trend_1(i,j)); 
    end 
end 
for j=1:49 
    for i=1:144 
        count=fwrite(fid,prg_trend_1(i,j),'double'); 
    end 
end 
fclose(fid) 
nc: 
nccreate('H:\data\pr.nc','prhf','dimensions',{'lon',144,'lat',49},'format','netcdf4_classic'); 
nccreate('H:\data\pr.nc','praf','dimensions',{'lon',144,'lat',49},'format','netcdf4_classic'); 
nccreate('H:\data\pr.nc','prgf','dimensions',{'lon',144,'lat',49},'format','netcdf4_classic'); 
ncwrite('H:\data\pr.nc','prhf',prh_trend_1); 
ncwrite('H:\data\pr.nc','praf',pra_trend_1); 
ncwrite('H:\data\pr.nc','prgf',prg_trend_1); 
 
其中nc文件出现了SDF file has no discernable X coordinate错误  
因此两个数据文件全部使用ctl文件描述  
ctl:  
Dset  h:\data\pr.nc 
Undef    -9999 
xdef  144  linear  0   2.5 
ydef  49  linear  -60   2.5 
zdef   1  levels  0 
tdef  1  linear  jan1979   1yr 
Vars  9 
prhf  1  99  please add notes 
prgf  1  99  please add notes  
praf  1  99  please add notes  
prhs  1  99  please add notes  
prgs  1  99  please add notes  
pras  1  99  please add notes  
prht  1  99  please add notes  
prgt  1  99  please add notes  
prat  1  99  please add notes  
Endvars 
但是无论是哪一种方式,画出来的图片总是如下 
我感觉应该是matlab写数据的时候有问题,但是实在找不出问题所在,请各位大神帮帮孩子吧 
 
 
  
 |   
- 
使用nc/dat文件画出来的错误图片 
 
 
 
 
 
 
 
 |