Remove decreasing data in matrix

8 vues (au cours des 30 derniers jours)
Emily Heil
Emily Heil le 18 Nov 2021
Commenté : Emily Heil le 18 Nov 2021
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?

Réponse acceptée

Matt J
Matt J le 18 Nov 2021
Modifié(e) : Matt J le 18 Nov 2021
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

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by