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 件のコメント

jonas
jonas 2018 年 10 月 9 日
relevant question for some context ( link )
+1 on the other approach. Could do something like:
TT(day(TT.Time)==28,:)
Manuel Flores
Manuel Flores 2018 年 10 月 9 日
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.
Walter Roberson
Walter Roberson 2018 年 10 月 9 日
Comparing that the day is less than or equal to 28 is sufficient since no day can be 0 or negative.
Manuel Flores
Manuel Flores 2018 年 10 月 9 日
Thank you got it working with that.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeTime Series Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by