필터 지우기
필터 지우기

Single average value for same range of time each day throughout the year

조회 수: 1 (최근 30일)
Hello,
I am currently looking for a way to average my dataset for a period of 4 minutes each day. For my current analysis, I am only interested in the specific value at 5pm (17:00:00). Sometimes though, this data point is missing, so I had thought to take an average from 16:58 to 17:02. I had attempted to work through this, using my test Time_Vector (attached) as a reference. My current code unfortunately also returns 16:00:00 - 16:01:59 as well as 17:58:00 - 17:59:59, so at this time I am unable to accurately average my dataset. I would then use the index created to split up my Time_Vector against my y-data to find a specific value each day.
(i.e. Test_Y = Test_Y(mt_id) or Test_Y = Test_Y(Times_to_Keep_id))
H = hour(Time_Vector);
hr_id = H >= 16 & H <= 17;
Time_Vector2 = Time_Vector(hr_id);
mt_id = minute(Time_Vector2) > 58 | minute(Time_Vector2) < 02;
Time_Vector3 = Time_Vector2(mt_id);
% Times_to_Keep_id = hr_id & mt_id;
Thank you for your help.

채택된 답변

Cris LaPierre
Cris LaPierre 2021년 1월 8일
편집: Cris LaPierre 2021년 1월 8일
You need to combine your conditions for hours and minutes. Consider using the timeofday function instead.
load Time_Vector
Tind = timeofday(Time_Vector) >= duration(16,58,0) & timeofday(Time_Vector) <= duration(17,02,0);
Time_Vector(Tind,1)
ans = 24×1 datetime array
19-Jul-2017 16:58:03 19-Jul-2017 16:58:18 19-Jul-2017 16:58:33 19-Jul-2017 16:58:48 19-Jul-2017 16:59:03 19-Jul-2017 16:59:18 19-Jul-2017 16:59:33 19-Jul-2017 16:59:48 19-Jul-2017 17:00:03 19-Jul-2017 17:00:18 19-Jul-2017 17:00:33 19-Jul-2017 17:00:48 19-Jul-2017 17:01:03 19-Jul-2017 17:01:18 19-Jul-2017 17:01:33 19-Jul-2017 17:01:48 20-Jul-2017 16:58:03 20-Jul-2017 16:58:18 20-Jul-2017 16:58:33 20-Jul-2017 16:58:48 20-Jul-2017 16:59:03 20-Jul-2017 16:59:18 20-Jul-2017 16:59:33 20-Jul-2017 16:59:48

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by