About unique command problem

1 回表示 (過去 30 日間)
C Zeng
C Zeng 2013 年 4 月 3 日
Hi,
I used unique(A,'rows') to find unique rows of matrix A, however, it has a problem that after picking unique rows, it will order them in a manner. That is bad to my problem, I want to keep the order as originally in A.
Is there a command that prohibits sorting rows but only deleting same rows(reserve the first appearance) in MATLAB?
Thanks

採用された回答

per isakson
per isakson 2013 年 4 月 3 日
Doc says:
[C,ia,ic] = unique(A,setOrder) and [C,ia,ic] = unique(A,'rows',setOrder) returns
C in a specific order. setOrder='sorted' returns the values (or rows) of C in
sorted order. setOrder='stable' returns the values (or rows) of C in the same
order as A.
Try
setOrder='stable'
  1 件のコメント
C Zeng
C Zeng 2013 年 4 月 3 日
Oh, thanks per isakson, I should be familiar with doc myself. :-)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpecial Functions についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by