Find common elements of two array with repetition????

1 回表示 (過去 30 日間)
div
div 2018 年 9 月 11 日
コメント済み: Image Analyst 2018 年 9 月 11 日
For example
A = [1234567]
B = [2348907]
now i hv to compare above two and want to store index of common elements.

回答 (1 件)

Stephen23
Stephen23 2018 年 9 月 11 日
編集済み: Stephen23 2018 年 9 月 11 日
[C,ia,ib] = intersect(A,B)
For example:
>> A = [1,2,3,4,5,6,7];
>> B = [2,3,4,8,9,0,7];
>> [C,ia,ib] = intersect(A,B)
C =
2 3 4 7
ia =
2 3 4 7
ib =
1 2 3 7
  4 件のコメント
div
div 2018 年 9 月 11 日
not working sir . Please help this out.
Image Analyst
Image Analyst 2018 年 9 月 11 日
It DOES work. I just copied and pasted and it worked fine. Post the code that you subsequently altered so we can see how your alterations ruined it.

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

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by