Create subsets of data within a timetable
이전 댓글 표시
I have a timetable (TT) and I need to create data subsets based on time duration vectors. The code below does what I need but I ended up with 6 timetables in my workspace, which is a problem for me because I then need to do a for loop to conduct several operations on each subset and I don't know how to iterate through different timetables. I would be so grateful if someone could tell me if there is a way to have these 6 subsets all in a single timetable so I can then have a loop iterating through them? Alternatively, how can I loop through my different timetables, considering they have different names (t1, t2, etc)? Thank you so much in advance for your help!
t1 = TT(timerange(hours(00), hours(04)), :);
t2 = TT(timerange(hours(04), hours(08)), :);
t3 = TT(timerange(hours(08), hours(12)), :);
t4 = TT(timerange(hours(12), hours(16)), :);
t5 = TT(timerange(hours(16), hours(20)), :);
t6 = TT(timerange(hours(20), hours(24)), :);
채택된 답변
추가 답변 (1개)
Peter Perkins
2017년 2월 8일
Another possibility is to keep the one timetable, but add a grouping variable to indicate which segment a given row is in. Then use either varfun or rowfun, specifying that grouping variable to work on each segment separately. Not sure what you're doing with each segment, so it's hard to give specific advice, but the first step probably looks something like
tt.Segment = discretize(tt.Time,hours(0:4:24),'categorical')
카테고리
도움말 센터 및 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!