Pulling interval ranges of data from a timetable

Hi Everyone I have a code like this where I pull the data based on those 4 dates from a timetable. That works, so no problem there.
% Pull the Temperature from the design dates.
Tr = {'2017-07-01','2017-07-02','2017-08-01','2017-08-02'};
Tj = TT_all(Tr,2);
Now I'm wondering how to do the same for 28 days, for every month over 12 months. Obviously it's not like this.
Tr_all = {'2017-07-01:2017-07-28','2017-08-02:2017-08-28','2017-09-01:2017-09-28'}...
{'2017-10-01:2017-10-28','2017-11-01:2017-11-28','2017-12-01:2017-12-28'}...
{'2018-01-01:2011-01-28','2018-02-01:2011-02-28','2018-03-01:2011-03-28'}...
{'2018-04-01:2011-04-28','2018-05-01:2011-05-28','2018-06-01:2011-06-28'};
can anyone point me in the right direction please. Thanks

 채택된 답변

Walter Roberson
Walter Roberson 2018년 10월 9일
편집: Walter Roberson 2018년 10월 9일

1 개 추천

https://www.mathworks.com/help/matlab/ref/timerange.html
However I am not sure if you can concatenate several of these together to form a single subscript. My memory from last year is that you cannot do that and so would have to handle the ranges separately.
Another approach would be to extract the day number from each and compare it to 28 to see if it was in range, making a logical mask that you could apply to the row indices.

댓글 수: 4

relevant question for some context ( link )
+1 on the other approach. Could do something like:
TT(day(TT.Time)==28,:)
Hey Walter I had a look at the timerange on mathworks before I posted this and couldn't find anything that gave me what I was looking for. You probably are correct and I have to do this differently, was just hoping that there was like a shortcut out there that someone knew.
Also I need from 1st - 28th. Sorry if that wasn't clearer.
Comparing that the day is less than or equal to 28 is sufficient since no day can be 0 or negative.
Thank you got it working with that.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Time Series Objects에 대해 자세히 알아보기

질문:

2018년 10월 9일

댓글:

2018년 10월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by