How can I match time series data to times in a different, smaller matrix?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
This is not homework, I am doing genuine research. So I have two files, one with data in half hour increments and one with sunrise and sunset times for each day. Basically, I want to be able to say "if its night time, do a certain calculation, if it's day time, do a different calculation" for each day in the 1st data set by referencing the second one based off the date Any help would be appreciated (could be a simple for loop), thanks! below is my code thus far (I know its not pretty):
%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;
O_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;
r_s=[sr_tm,ss_tm]; %creates array of rise and set times
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Dates and Time finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!