气象数据处理
氣象數據處理
%--------------------------------------------
% 全國降水網格月數據累加成年數據
%--------------------------------------------
FolderPath=input(‘請輸入數據存儲文件夾:’,‘s’); %輸入字符串給FolderPath,不帶s則為默認輸入數值
index=strfind(FolderPath,’’);? %輸出字符’‘在FolderPath的位置
SaveFolder=strcat(FolderPath(1:index(end)),‘resultmonthtoyear’); %輸出文件夾路徑
if exist(SaveFolder,‘dir’)~=7? %如果路徑不存在則新建路徑
??? mkdir(SaveFolder)
end
Files=dir(FolderPath);
FilesCount=length(Files);
disp(‘處理中…’);
for i=1:50??????????????????????? %1961-2010年
? rain_year=zeros(72,128);
? for k=(3+12*(i-1)):(12*i+2);
??? rain=zeros(72,128);
??? FilePath=strcat(FolderPath,’’,Files(k).name);? %文件路徑\文件名
??? Name=Files(k).name;
??? location=strfind(Name,’.’);? %輸出字符’.‘在FolderPath的位置
??? SaveFiles=strcat(‘SURF_CLI_CHN_PRE_YEAR_GRID_0.5-’,Name(location(end)-6:location(end)-3),’.txt’); %輸出文件夾路徑
??? rain_temp=textread(FilePath,’%f’,‘headerlines’,6);? % 讀取數據,%f是小數點形式的浮點數, 從第6行開始讀,headerlines表示開頭跳過幾行,textread:按行讀數據,將所有數據讀入一列
??? rain=reshape(rain_temp,128,72)’;? %reshape把指定的矩陣改變形狀,但是元素個數不變
??? for? i=1:72
????? for j=1:128
?????? rain_year(i,j)=rain_year(i,j)+rain(i,j);
????? end
??? end
? end
總結
- 上一篇: vue实现监听滚动条
- 下一篇: weblogic安全漫谈