repeating numbers in an array

2 ビュー (過去 30 日間)
Muhammad Asim
Muhammad Asim 2017 年 9 月 13 日
コメント済み: Muhammad Asim 2017 年 9 月 15 日
i have a problem i have a large array i want to check if there is a repeating number in that array; if yes than detect.?

採用された回答

KL
KL 2017 年 9 月 13 日

その他の回答 (1 件)

Steven Lord
Steven Lord 2017 年 9 月 13 日
Do you want to detect repeated numbers anywhere in the array (you want to detect both [1 2 2 3 1] and [1 2 3 1 2]) or just repeated numbers adjacent to one another (detect [1 2 2 3 1] but not [1 2 3 1 2])? In the latter case, take a look at the diff function.
In the former case, the unique function would work as KL suggested. Alternately, if your numbers are floating-point values and you want to consider two numbers repeated if they are "close enough" take a look at the uniquetol function. Depending on the exact information you want there may be other approaches that use less memory and/or time.
  • Do you just want to know whether there is or is not a repeated element (existence?)
  • Do you want to know how many repeated elements (count?)
  • Do you want to know where they are (location?)
  1 件のコメント
Muhammad Asim
Muhammad Asim 2017 年 9 月 15 日
dear sir. I just want to know if there is any repeating number in the array, no matters how many times?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeOperators and Elementary Operations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by