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

19 Ansichten (letzte 30 Tage)
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.

Akzeptierte Antwort

jonas
jonas am 28 Sep. 2018
Bearbeitet: jonas am 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 Kommentare
Thomas Burbey
Thomas Burbey am 28 Sep. 2018
That works. Thanks you. Way easier than the approach I was taking.
Peter Perkins
Peter Perkins am 1 Okt. 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Timetables finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by