Delete rows with same elements
Show older comments
a=[2 3 2;3 3 3;4 4 4;2 5 4; 3 5 5; 4 4 4; 7 3 4]
how do I delete only those rows where elemets repeat for entire row length. In this example matrix, the three rows with all 3s and all 4s where this happens.
Accepted Answer
More Answers (1)
Walter Roberson
on 25 Nov 2018
mask = all(diff(a, [], 2) == 0)
Now you can use mask as the row selector in deletion.
1 Comment
Walter Roberson
on 26 Nov 2018
a(mask,:) = [];
Categories
Find more on Correlation and Convolution 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!