|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
clear
clc
%设定读取写入路径
runpath=pwd;
cd ..
pathback1=pwd;
cd ..
pathback2=pwd;
cd(runpath)
ReadPath=['E:\yiyue\'];
WritePath1=['F:\metadata\NEC\2009\GLOBAL\'];
WritePath2=['F:\metadata\NEC\2009\CHINA\'];
WritePath3=['F:\metadata\NEC\2009\NORTHCHINA\'];
% WritePath=[pathback1 '\\'];
% mkdir([WritePath])
%
% ReadFile=dir([ReadPath 'MBO200501*.min']);
ReadFile=dir([ReadPath '*.cdf']);
for iRead=1:length(ReadFile);
%读入文件
ReadFileName=ReadFile(iRead).name;
disp([ReadFileName]);
data=cdfread([ReadPath ReadFileName]);
n1=strcat(WritePath1,ReadFileName,'.dat');
n2=strcat(WritePath2,ReadFileName,'.dat');
n3=strcat(WritePath3,ReadFileName,'.dat');
% 创建保存数据文件
f1=fopen(n1,'w');
f2=fopen(n2,'w');
f3=fopen(n3,'w');
k=0;
kk=0;
for i=1:size(data,1)
fprintf(f1,'%6i',i);
fprintf(f1,' ');
d1=data{i,1};
mdate=todatenum(d1);
%[y m d h mi sec]=datevec(mdate);
g=datevec(mdate);
d2=data{i,2};
d3=data{i,3};
d4=data{i,4};
d5=data{i,5};
d6=data{i,7};
fprintf(f1,'%4i %2i %2i %2i %2i ',g(1:5));
sec1=floor(g(6));
fprintf(f1,'%2i',sec1);
fprintf(f1,' ');
fprintf(f1,'%7.3f',d2);
fprintf(f1,' ');
fprintf(f1,'%8.3f',d3);
fprintf(f1,' ');
fprintf(f1,'%6.2f',d4);
fprintf(f1,' ');
fprintf(f1,'%4.1f %4.1f ',d5);
fprintf(f1,' ');
fprintf(f1,'%12.3f %12.3f %12.3f',d6);
fprintf(f1,'\r');
%data for CHINA
if (d2>=15.d0&d2<=55.d0)&(d3>=70.d0&d3<=135.d0)
kk=kk+1;
fprintf(f2,'%6i',kk);
fprintf(f2,' ');
fprintf(f2,'%4i %2i %2i %2i %2i ',g(1:5));
sec1=floor(g(6));
fprintf(f2,'%2i',sec1);
fprintf(f2,' ');
fprintf(f2,'%7.3f',d2);
fprintf(f2,' ');
fprintf(f2,'%8.3f',d3);
fprintf(f2,' ');
fprintf(f2,'%6.2f',d4);
fprintf(f2,' ');
fprintf(f2,'%4.1f %4.1f ',d5);
fprintf(f2,' ');
fprintf(f2,'%12.3f %12.3f %12.3f',d6);
fprintf(f2,'\r');
end
%data for North CHINA
if (d2>=30.d0&d2<=45.d0)&(d3>=105.d0&d3<=125.d0)
k=k+1;
fprintf(f3,'%6i',k);
fprintf(f3,' ');
fprintf(f3,'%4i %2i %2i %2i %2i ',g(1:5));
sec1=floor(g(6));
fprintf(f3,'%2i',sec1);
fprintf(f3,' ');
fprintf(f3,'%7.3f',d2);
fprintf(f3,' ');
fprintf(f3,'%8.3f',d3);
fprintf(f3,' ');
fprintf(f3,'%6.2f',d4);
fprintf(f3,' ');
fprintf(f3,'%4.1f %4.1f ',d5);
fprintf(f3,' ');
fprintf(f3,'%12.3f %12.3f %12.3f',d6);
fprintf(f3,'\r');
end
end
fclose(f1);
fclose(f2);
fclose(f3);
end |
|