フィルターのクリア

Remove decreasing data in matrix

8 ビュー (過去 30 日間)
Emily Heil
Emily Heil 2021 年 11 月 18 日
コメント済み: Emily Heil 2021 年 11 月 18 日
I have a 2 column matrix with several thousand rows. In one column of the matrix, the data cyclicly increases and decreases. I want to remove all rows where the data is decreasing.
For example if my matrix looked like this:
rawdata = [1 2
2 2
3 2
4 2
5 2
4 2
3 2
2 2
1 2
2 2
3 2
4 2
5 2];
I'd want to remove rows 6-9.
Can anyone help?

採用された回答

Matt J
Matt J 2021 年 11 月 18 日
編集済み: Matt J 2021 年 11 月 18 日
rawdata = [1 2
2 2
3 2
4 2
5 2
4 2
3 2
2 2
1 2
2 2
3 2
4 2
5 2];
rawdata( [false; diff(rawdata(:,1))<0] , : )=[]
rawdata = 9×2
1 2 2 2 3 2 4 2 5 2 2 2 3 2 4 2 5 2
  1 件のコメント
Emily Heil
Emily Heil 2021 年 11 月 18 日
thank you!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by