登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
各位大神请问采用matlab的interp2插值的时候报是怎么回事啊,我想把124个文件中的变量ts从0.5度插值到0.05度,小白求助啊55555跪谢各位了错误使用 griddedInterpolant网格矢量未定义与给定值匹配的点网格。
出错 interp2>makegriddedinterp (line 229) F = griddedInterpolant(varargin{:});
出错 interp2 (line 137) F = makegriddedinterp(X, Y, V, method,extrap); 代码如下 list=dir(['/home/need/tsnc/','*.nc']) i=length(list)
for k=1:i str=strcat('/home/need/tsnc/',list(i).name) ts=ncread(str,'ts') lon=ncread(str,'lon') lat=ncread(str,'lat') %交换南北纬,原数据维度是递减的 for m=1:61 for n=1:41 tsy(m,n)=ts(m,(42-n)) end end
[X,Y]=meshgrid(lon,lat) YI=(30:0.05:50) XI=(120:0.05:150) [XXI,YYI]=meshgrid(XI,YI); tts=interp2(X,Y,tsy,XXI,YYI) ttts(:,:)=tts(:,:) if k<10 filename1=strcat('/home/need/tsnc/cha00',int2str(k),'.nc') elseif k<100 filename1=strcat('/home/need/tsnc/cha0',int2str(k),'.nc') else filename1=strcat('/home/need/tsnc/cha',int2str(k),'.nc') end ncid=netcdf.create(filename1,'CLOBBER'); dimidx=netcdf.defDim(ncid,'lon',401) dimidy=netcdf.defDim(ncid,'lat',601);
varid1=netcdf.defVar(ncid,'ts','double',[dimidx,dimidy]);
varid2=netcdf.defVar(ncid,'lon','float',[dimidx]); varid3=netcdf.defVar(ncid,'lat','float',[dimidy]); netcdf.putAtt(ncid,varid1,'units','K'); netcdf.putAtt(ncid,varid2,'units','degree_east'); netcdf.putAtt(ncid,varid3,'units','degree_north'); netcdf.endDef(ncid); netcdf.endDef(ncid); netcdf.putVar(ncid,varid1,ttts); netcdf.putVar(ncid,varid2,YI);netcdf.putVar(ncid,varid3,XI); netcdf.close(ncid); end
|