|
楼主 |
发表于 2006-3-28 12:06
|
显示全部楼层
<P>谢谢happy教授<BR>读取数据我用的是fscanf,程序是这样写的,帮我看看,谢谢<BR><BR>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<BR>%文件经纬度的起始范围 lon0&lat0; 结束范围 lon1&lat2;m0&n0为要平滑点的经纬度<BR>lon0=50;<BR>lat0=30;<BR>lon1=100;<BR>lat1=60;<BR>m0=lon0+2.5:1:lon1-2.5; %格点为2.5*2.5<BR>n0=lat0-2.5:1:lat1+2.5; %格点为2.5*2.5<BR>%确定打开的文件名<BR>file1='K:\ecmwf\temper\850'; %文件位置<BR>date1=???; %读取的开始位置 <BR>date2=???; %读取的结束位置<BR>for i=date1:date2<BR>file2=int2str(i);<BR>file3='20.024';<BR>file4='20.048';<BR>file5='20.072';<BR>file6='20.096';<BR>file7='20.120';<BR>file8='0';<BR>if (i-1)< ???<BR>file=[file1 file8 file2 file3 file4 file5 file6 file7]<BR>else<BR>file=[file1 file2 file3 file4 file5 file6 file7]<BR>end<BR>fid=fopen(file,'r');<BR>%这样写最麻烦的是我还需要自己去数我要读取的数据的开始位置和结束位置,<BR>%更要命的是我要读取的部分中还有不少缺少的,不能顺读<BR>% 读字符行 <BR>ch1=fgetl(fid);<BR>ch2=fgetl(fid);<BR>ch3=fgetl(fid);<BR>ch4=fgetl(fid);<BR>ch5=fgetl(fid);<BR>ch6=fgetl(fid);<BR>ch7=fgetl(fid);<BR>% 数据读取<BR>shuju1=(fscanf(fid,'%f',[151,61]))';<BR>shuju2=(fscanf(fid,'%f',[151,61]))';<BR>shuju3=(fscanf(fid,'%f',[151,61]))';<BR>shuju4=(fscanf(fid,'%f',[151,61]))';<BR>shuju5=(fscanf(fid,'%f',[151,61]))';<BR>%进行上下左右五点平滑<BR>shuju1(i)=(shuju(m0+1,n0)+shuju(m0-1,n0)+shuju(m0,n0)+shuju(m0,n0+1)+shuju(m0,n0-1))/5;<BR>shuju2(i)=(shuju(m0+1,n0)+shuju(m0-1,n0)+shuju(m0,n0)+shuju(m0,n0+1)+shuju(m0,n0-1))/5;<BR>shuju3(i)=(shuju(m0+1,n0)+shuju(m0-1,n0)+shuju(m0,n0)+shuju(m0,n0+1)+shuju(m0,n0-1))/5;<BR>shuju4(i)=(shuju(m0+1,n0)+shuju(m0-1,n0)+shuju(m0,n0)+shuju(m0,n0+1)+shuju(m0,n0-1))/5;<BR>shuju5(i)=(shuju(m0+1,n0)+shuju(m0-1,n0)+shuju(m0,n0)+shuju(m0,n0+1)+shuju(m0,n0-1))/5;<BR>end<BR>num=date2;<BR>shuju00(1:num,1)=(shuju1)';<BR>shuju00(1:num,2)=(shuju2)';<BR>shuju00(1:num,3)=(shuju3)';<BR>shuju00(1:num,4)=(shuju4)';<BR>shuju00(1:num,5)=(shuju5)';<BR>%写数据也让我头疼,再次感谢教授的指导!~<BR></P> |
|