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

2 次查看(过去 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?

采纳的回答

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 个评论
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 CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by