How to subcategorize dates from a datetime table?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi all,
I have a datetime table in this Period.mat file (attached) where I have a date list starting from 01/01/2005 to 12/31/2019. I want to sub-categorize the datetime table like this -
01/01/2005 to 12/31/2007
06/01/2006 to 06/31/2008
01/01/2007 to 12/31/2009
06/01/2008 to 06/31/2010
01/01/2009 to 12/31/2011
06/01/2010 to 06/31/2012
........
......
....
01/01/2017 to 12/31/2019
06/01/2018 to 06/31/2019
Eahc of these date range can be in an array. So, there will be a big cell array that contains each of these sub group. Can anyone please give me an idea on how to do that?
Any feedback will be highly appreciated!
댓글 수: 0
채택된 답변
Steven Lord
2023년 4월 4일
If you have a timetable use a timerange to index into it to retrieve the appropriate section of the timetable then perform whatever calculations you need on those sections. I don't think groupsummary will do what you want here because the groups overlap.
댓글 수: 3
Peter Perkins
2023년 4월 5일
Much as in your other similar question, I thiknk you want to end up with a table that has your timerange's (or maybe a text representation, or maybe both) in one variable, and a cell array containing different-length datetime vectors in another.
As Steve says, you can't use groupsummary or a grouped varfun here, because the "groups" overlap. You'll need to loop and use each timerange separately.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!