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

2 visualizaciones (últimos 30 días)
Igor Batoukhtine
Igor Batoukhtine el 28 de Abr. de 2016
Comentada: Star Strider el 28 de Abr. de 2016
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?

Respuesta aceptada

Star Strider
Star Strider el 28 de Abr. de 2016
Editada: Star Strider el 28 de Abr. de 2016
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 comentarios
Igor Batoukhtine
Igor Batoukhtine el 28 de Abr. de 2016
Aaaah great, thanx! I was looking at the wrong page:
Star Strider
Star Strider el 28 de Abr. de 2016
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by