フィルターのクリア

How to find repeated values in an array?

7 ビュー (過去 30 日間)
Yro
Yro 2020 年 12 月 9 日
回答済み: Matt J 2020 年 12 月 10 日
How can I find repeated values by columns in an array (12x2)?
A = 26 24
28 35
31 34
33 31
33 31
33 28
35 25
31 26
30 26
28 29
27 30
26 32
As can be seen, the repeated values are [33 31]. I tried to use the unique function but it only finds the unique values in a column.
[C1, ia1, ic1] = unique(A(:,1),'stable', 'rows');
Thanks in advance.

回答 (1 件)

Matt J
Matt J 2020 年 12 月 10 日
A = [26 24
28 35
31 34
33 31
33 31
33 28
35 25
31 26
30 26
28 29
27 30
26 32];
[C1, ia1, ic1] = unique(A,'stable', 'rows');
reps=C1(splitapply(@numel,ic1,ic1)>1 ,:)
reps = 1×2
33 31

カテゴリ

Help Center および File ExchangeConstruct and Work with Object Arrays についてさらに検索

タグ

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by