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 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