Finding same values in uneven arrays

1 回表示 (過去 30 日間)
Jens Keijser
Jens Keijser 2018 年 5 月 9 日
コメント済み: Jens Keijser 2018 年 5 月 9 日
Hello,
I need help with finding true positives. A have an array with all the moments a certain event occurs. And I have an array with all the moments my algorithm detected the event. The arrays are not even lengths. For example:
Array 1 (always the same length):
3 4 5 6 7 20 21 22 23 24 25 26
Array 2 (can vary in length):
1 2 3 5 6 23 24 28 29 30 102 160 171 189 190
So I want the number I of times the arrays share the same number. In this case that will be 5 times, which means there are 5 true positives.
Can someone help me with this?
Thankyou in advance!!

採用された回答

sloppydisk
sloppydisk 2018 年 5 月 9 日
Use the ismember function.
A = [3 4 5 6 7 20 21 22 23 24 25 26];
B = [1 2 3 5 6 23 24 28 29 30 102 160 171 189 190];
positives = sum(ismember(A, B))
  1 件のコメント
Jens Keijser
Jens Keijser 2018 年 5 月 9 日
Thank you very much!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Identification についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by