How do I make a loop that goes through day by day?

1 次查看(过去 30 天)
I for that day am doing research and need to create a loop that goes through day by day and also includes the appropriate sunrise and sunset times starting at line "day_2=...". my data looks like; "date/time | data | data | data " where date/time goes in half hour increments and: "date | time_sunrise | time_sunset" where date goes by day.
%Hudson River Water Quality 1995-2000
data=xlsread('Hudson_test1.xlsx');
tm=data(:,1)+datenum(1904,1,1);
[yr,mo,day,hr,min]=datevec(tm);
DO_p=data(:,5);
DO=data(:,6);
z=data(:,7);
dif_DO=DO(2:end)-DO(1:end-1);
air_sea=(1-((DO_p(1:end-1)+DO_p(2:end))/200))*0.5*0.5;
do_flux=(dif_DO.*z(2:end))-air_sea;
sun=xlsread('rise_set_test.xls');
tm_sun=sun(:,1)+datenum(1904,1,1);
[yr_s,mo_s,day_s]=datevec(tm_sun);
rise=(sun(:,2));
set=sun(:,3);
%put sunrise and sunset into proper matlab date format
srh=floor(rise/100);
srm=rise-100*srh;
sr=(srh+srm/60)/24;
sr_tm=sr+tm_sun; %puts in date format
ssh=floor(set/100);
ssm=set-100*ssh;
ss=(ssh+ssm/60)/24 ;
ss_tm=ss+tm_sun;
day_2 = tm(2:96);
j_2 = day_2>=sr_tm(2,1) & day_2<=ss_tm(2,1);
m_2 = day_2<=sr_tm(2,1) & day_2>=tm(49,1) |day_2>=ss_tm(2,1);
do_dy_2 = sum(do_flux(j_2));
do_nt_2 = sum(do_flux(m_2));
resp_rt_2 = (do_nt_2.*(-1))/(nnz(m_2)/2);
ttl_resp_2 = resp_rt_2.*24;
day_resp_2 = resp_rt_2.*(nnz(j_2)/2);
gp_2 = day_resp_2 + do_dy_2;
NEM_2 = gp_2-ttl_resp_2;

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by