What does the 'i' mean in [y,i] = unique(A)?
4 ビュー (過去 30 日間)
古いコメントを表示
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?
0 件のコメント
採用された回答
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 件のコメント
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 Exchange で Matrix Indexing についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!