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

 Respuesta aceptada

Walter Roberson
Walter Roberson el 9 de Oct. de 2018
Editada: Walter Roberson el 9 de Oct. de 2018

1 voto

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 comentarios

relevant question for some context ( link )
+1 on the other approach. Could do something like:
TT(day(TT.Time)==28,:)
Manuel Flores
Manuel Flores el 9 de Oct. de 2018
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.
Manuel Flores
Manuel Flores el 9 de Oct. de 2018
Thank you got it working with that.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Etiquetas

Preguntada:

el 9 de Oct. de 2018

Comentada:

el 9 de Oct. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by