Pulling interval ranges of data from a timetable

3 vues (au cours des 30 derniers jours)
Manuel Flores
Manuel Flores le 9 Oct 2018
Commenté : Manuel Flores le 9 Oct 2018
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

Réponse acceptée

Walter Roberson
Walter Roberson le 9 Oct 2018
Modifié(e) : Walter Roberson le 9 Oct 2018
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 commentaires
Walter Roberson
Walter Roberson le 9 Oct 2018
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 le 9 Oct 2018
Thank you got it working with that.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Dates and Time dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by