How can I strip duplicates?
조회 수: 2 (최근 30일)
이전 댓글 표시
I wish to remove all duplicate rows based off of the first column. That is, I want to just strip the excess away. I am struggling to understand how to implement "unique" here. Thanks in advance
답변 (1개)
Fangjun Jiang
2021년 4월 9일
If you want
- remove duplicates only based on values in the first column
- Do not want the returned values be sorted
then you need to do this
in=[[5;5;5;4;4;4;3;3;3;1],(1:10)'];
[~, index]=unique(in(:,1),'stable');
out=in(index,:)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!