How can I delete array rows with same numbers
이전 댓글 표시
Hello,
I am having trouble finding a way to delete rows in my array with the same numbers.
For example I want to turn X=[123; 234; 213; 435] into X=[123; 234; 435] because rows 1 and 3 have the same numbers.
I've tried coming up with solutions using using "sort" and "unique" but can't quite figure it out. I'll be working with an array around 1225x3 with positive and negative numbers.
Also, every row adds up to equal the same number.
Thanks for any help you guys can give.
답변 (2개)
Walter Roberson
2012년 4월 29일
[sortedrows, ia] = unique(X,'rows');
newX = X(sort(ia,:));
Andrei Bobrov
2012년 4월 29일
[b b]=unique(sort(X,2),'rows','first');
out = X(sort(b),:)
카테고리
도움말 센터 및 File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!