How can I match time series data to times in a different, smaller matrix?
조회 수: 2 (최근 30일)
이전 댓글 표시
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Automated Driving Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!