Selecting rows based on criteria from previous row
Show older comments
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
Answers (1)
Andrei Bobrov
on 14 Nov 2015
Edited: Andrei Bobrov
on 14 Nov 2015
c - your array [72 x 3]
x = c(:,1) == 0;
out = c([false;x(1:end-1)],:);
1 Comment
sam dewitt
on 14 Nov 2015
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!