Borrar filtros
Borrar filtros

Removing rows in a timetable that don't meet certain criteria

12 visualizaciones (últimos 30 días)
I've created a timetable that has daily values of precipitation for a large number of years. I want to use retime to obtain the annual total precipitation. That is AnnSum = retime(TT,'yearly','sum'). However, there are some years where there aren't a sufficient number of days of data to include in the annual record. I determine this using retime with count. That is, AnnFlg = retime(TT,'yearly','count'). If count is less than 350 I want to remove that year from the timetable altogether. I've tried doing this with for loops and if statements but it doesn't seem to like using Timetables in this way. Not sure how to do this. Any help would be appreciated.

Respuesta aceptada

jonas
jonas el 28 de Sept. de 2018
Editada: jonas el 28 de Sept. de 2018
I suspect that you are using the wrong type of braces. Remember that TT{r,c} outputs the data in double-format while TT(r,c) returns part of the timetable. In order to make logical operations, you need the data in double format, but you need to specify the rows to delete with ().
I assume your timetables only have a single column each with variables. TT is your timetable and C is your timetable with counts.
TT(C{:,1}<350,:)=[]
if your counts are not located in the first column of C (excluding the time-stamps), then you need to select the appropriate column where the counts are present.
  2 comentarios
Thomas Burbey
Thomas Burbey el 28 de Sept. de 2018
That works. Thanks you. Way easier than the approach I was taking.
Peter Perkins
Peter Perkins el 1 de Oct. de 2018
This
TT(C.CountVar<350,:) = []
would also work (replace "CountVar" with the real name), and some people find the dot notation easier to understand.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Timetables en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by