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.
댓글 수: 0
채택된 답변
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)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!