フィルターのクリア

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

12 ビュー (過去 30 日間)
Thomas Burbey
Thomas Burbey 2018 年 9 月 28 日
コメント済み: Peter Perkins 2018 年 10 月 1 日
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.

採用された回答

jonas
jonas 2018 年 9 月 28 日
編集済み: jonas 2018 年 9 月 28 日
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 件のコメント
Thomas Burbey
Thomas Burbey 2018 年 9 月 28 日
That works. Thanks you. Way easier than the approach I was taking.
Peter Perkins
Peter Perkins 2018 年 10 月 1 日
This
TT(C.CountVar<350,:) = []
would also work (replace "CountVar" with the real name), and some people find the dot notation easier to understand.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTimetables についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by