Find index of same values in array
이전 댓글 표시
Hi all,
i have to find the index of the same value in an array,see the following example
a=[1 2 3 1]
i want b=[1 4] as output..how can i do this? A solution using find is this
- u=unique(a)
- n=histc(a,u)
- find(a==u(n>1))
but if in the a array there isn't 2 or more same value i get this error
??? Error using ==> eq Matrix dimensions must agree.
Thank you for your support :-)
댓글 수: 1
Walter Roberson
2014년 1월 28일
What if there are multiple repeated values?
채택된 답변
추가 답변 (1개)
Pramod Kumar Jangir
2019년 10월 20일
0 개 추천
Hi Andrei,
your code only wokrs for the consecutive equal values. Could you please modify it for random same values in an array?
Pramod
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!