Delete rows with same elements
显示 更早的评论
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.
采纳的回答
更多回答(1 个)
Walter Roberson
2018-11-25
mask = all(diff(a, [], 2) == 0)
Now you can use mask as the row selector in deletion.
1 个评论
Walter Roberson
2018-11-26
a(mask,:) = [];
类别
在 帮助中心 和 File Exchange 中查找有关 Correlation and Convolution 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!