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!