timerange subscript within a timetable
이전 댓글 표시
End goal:
timeTableTT14to22 = timeTableTT(hours(14) <= timeofday(timeTableTT.Date) & timeofday(timeTableTT.Date) <= hours(22), :);
is there a bettwe way to do this ... using a timerange such as:
range14to22 = timerange(hours(14), hours(22), 'closed');
Essentially, having a multi-day / multi-year table with the Date column as a 10 minute interval datetime such as this:
2010-01-05 18:00
2010-01-05 18:10
2010-01-05 18:20
2010-01-05 18:30
2010-01-05 18:40
2010-01-05 18:50
2010-01-05 19:00
2010-01-05 19:10
2010-01-05 19:20
2010-01-05 19:30
How do you extract a daily timerange from such a table in a more elegant way, than the above? (say, you want a timetable with all the lines falling between 14 and 22 included).
And how do you marry this with other filters, such as - exclude bank holidays and sundays, for example, in an elegant and succint way?
Another example, extract year 2020:
timeTableTT(year(timeTableTT.Date) == 2020, :)
or this:
timeTableTT2020FirstHalf = timeTableTT2020(isbetween(timeTableTTTT2020.Date, datetime('2020-01-01'), datetime('2020-06-30'), 'closed'), :);
just feels awkwardly long and unnatural ... am I missing a better way to do subscripts like this?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Calendar에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
