What does the 'i' mean in [y,i] = unique(A)?

2 ビュー (過去 30 日間)
Igor Batoukhtine
Igor Batoukhtine 2016 年 4 月 28 日
コメント済み: Star Strider 2016 年 4 月 28 日
If I got a m x 1 matrix and I perform this little piece of code in Matlab it returns two arrays 'y' and 'i', where 'y' holds the unique numbers en 'i' holds the row numbers of the unique numbers? I don't understand why this is. Can someone explain this to me?

採用された回答

Star Strider
Star Strider 2016 年 4 月 28 日
編集済み: Star Strider 2016 年 4 月 28 日
It’s the index into ‘A’, so that ‘y=A(i)’. It returns the index of the first instance of the unique values. If you want all of them (indirectly), you have to ask for the third argument as well.
  4 件のコメント
Igor Batoukhtine
Igor Batoukhtine 2016 年 4 月 28 日
Aaaah great, thanx! I was looking at the wrong page:
Star Strider
Star Strider 2016 年 4 月 28 日
My pleasure!
That isn’t the ‘wrong’ page, and is definitely worth reading (I wish more posters here read it), but not the one that would provide the information you need to understand the unique function.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by