inputfilepreparation.m

来自「MATLAB语言下的(有源码):Mike Zero系列软件的前后处理 GE中岸线」· M 代码 · 共 18 行

M
18
字号
function [TimeNum]=InputFilePreparation(StartTime,TimeStep,EndTime,Longitude,Latitude)
AllTime=StartTime:TimeStep:EndTime;
%%
Fid_Input=fopen('tidepre_time.dat','w');
if Fid_Input<0
    error('tidepre_time.dat文件正在使用中,无法进行写操作!');
end
%%
TimeNum=length(AllTime);
StationNum=length(Longitude);
for c2=1:TimeNum
    for c1=1:StationNum
        CurrentDateStr=strrep(datestr(AllTime(c2),29),'-',' ');
        CurrentHour=hour(AllTime(c2))+minute(AllTime(c2))./60+second(AllTime(c2))./3600;
        fprintf(Fid_Input,'%.10f %.10f %s %.4f\n',Longitude(c1),Latitude(c1),CurrentDateStr,CurrentHour);
    end
end
fclose(Fid_Input);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?