フィルターのクリア

Finding common elements in an array (even if they are not in the same position)

3 ビュー (過去 30 日間)
cgo
cgo 2022 年 7 月 21 日
回答済み: Matt J 2022 年 7 月 21 日
I have two vectors a and b. Both vectors may not be of the same length. I want to find the common elements between these vectors. For example, if the number 1 appears in both vectors a and b, then i should output 1 and all other common elements.
I am struggling to think of how to do this. Any insights? Thanks

採用された回答

Matt J
Matt J 2022 年 7 月 21 日
a=1:10
a = 1×10
1 2 3 4 5 6 7 8 9 10
b=[1,11]
b = 1×2
1 11
c=intersect(a,b)
c = 1

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by