Remove decreasing data in matrix

8 次查看(过去 30 天)
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by