How to detect the repetition of any number in a array?
조회 수: 1 (최근 30일)
이전 댓글 표시
Say a=[4 5 8 9 4], How to detect this set has repeated numbers? I do not want to know the number, I just want to know that "a set has repeated numbers or not"
댓글 수: 0
채택된 답변
KSSV
2017년 8월 21일
Check unique. If the length of your array and length of unique are not same it has repeated numbers.
a=[4 5 8 9 4] ;
b = unique(a) ;
if length(a)~=length(b)
fprintf('array has repeated numbers\n')
else
fprintf('array has no repeated numbers\n')
end
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!