Azzera filtri
Azzera filtri

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

12 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

jonas
jonas il 28 Set 2018
Modificato: jonas il 28 Set 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 Commenti
Thomas Burbey
Thomas Burbey il 28 Set 2018
That works. Thanks you. Way easier than the approach I was taking.
Peter Perkins
Peter Perkins il 1 Ott 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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Timetables in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by