How to eliminate duplicate rows without sorting column in Matlab
5 ビュー (過去 30 日間)
古いコメントを表示
Hi,
Here is one problem that maybe some people will find useful to them.
I got matrix, lets say 500x9. In this matrix some rows are identical so they have to be eliminated. But the 3rd column musn't be sorted. This must be unchanged. All other columns can be changed (sorted).
I tryed this with function unique, but it sort me 3rd column.
Thank you in advance.
Have a nice day,
Nejc
0 件のコメント
回答 (1 件)
Azzi Abdelmalek
2013 年 4 月 4 日
unique(A,'stable')
4 件のコメント
Azzi Abdelmalek
2013 年 4 月 4 日
Edit
A=[1 2;3 5;1 2;0 2;0 2]
[~,idx]=unique(A,'rows','first')
out=A(sort(idx),:)
参考
カテゴリ
Help Center および 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!