Selecting rows based on criteria from previous row
Afficher commentaires plus anciens
Hello, I'm attempting to select specific rows of a matrix (size of which is (72,3) ) based on the criteria that the value of column 1 in the previous row = 0. So something
i = 1:72 X(i -1,1)==0? I've tried several different variations on this. I've also attempted naming rows with zero in the first column as something specific and selecting based on that, but can't seem to get it to work. Any help would be greatly appreciated it, thanks!
Sam DeWitt
Réponses (1)
Andrei Bobrov
le 14 Nov 2015
Modifié(e) : Andrei Bobrov
le 14 Nov 2015
c - your array [72 x 3]
x = c(:,1) == 0;
out = c([false;x(1:end-1)],:);
1 commentaire
sam dewitt
le 14 Nov 2015
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!