Check if there are repeated elements in a vector
조회 수: 45 (최근 30일)
이전 댓글 표시
Hi to all, is there a command to check if there are repeated elements in a vector; I just have to check in an "if"...
thanks a lot
Max
댓글 수: 0
채택된 답변
Image Analyst
2012년 12월 4일
if length(v) == length(unique(v))
% There are no repeats.
.......
댓글 수: 6
Yasir Iqbal
2021년 11월 25일
You can simply craete a copy of the vector with the required amount of values. There can be other ways around also. Just a suggestion.
Image Analyst
2021년 11월 25일
@Larissa Monjaraz I don't understand because you forgot to provide your example with actual numbers. So about all I can say is to try ismember().
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!