Effacer les filtres
Effacer les filtres

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

12 vues (au cours des 30 derniers jours)
Thomas Burbey
Thomas Burbey le 28 Sep 2018
Commenté : Peter Perkins le 1 Oct 2018
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.

Réponse acceptée

jonas
jonas le 28 Sep 2018
Modifié(e) : jonas le 28 Sep 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 commentaires
Thomas Burbey
Thomas Burbey le 28 Sep 2018
That works. Thanks you. Way easier than the approach I was taking.
Peter Perkins
Peter Perkins le 1 Oct 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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Timetables 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