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?

 Akzeptierte Antwort

Matt J
Matt J am 18 Nov. 2021
Bearbeitet: Matt J am 18 Nov. 2021

0 Stimmen

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

Weitere Antworten (0)

Gefragt:

am 18 Nov. 2021

Kommentiert:

am 18 Nov. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by