Relative occurance of intersect values

2 ビュー (過去 30 日間)
Gabriel Stanley
Gabriel Stanley 2022 年 9 月 20 日
コメント済み: Star Strider 2022 年 9 月 22 日
Is there a way to vectorize the below, and/or a better way to go about it?
A = %some set of numbers
B = %another set of numbers
C = intersect(A,B);
for temp = 1:numel(C)
C(temp,2) = numel(find(A==C(temp,1)));
C(temp,3) = numel(find(B==C(temp,1)));
end
I've tried using histcounts(A,C), however that returned 1 fewer bins that required, and just adding an arbitrary additional bin edge to either side does not get histcounts to give me what I'm looking for.

採用された回答

Star Strider
Star Strider 2022 年 9 月 20 日
The intersect funciton can output the indices of the intersecting elements. See Intersection of Two Vectors and Their Indices for an illustration.
  4 件のコメント
Star Strider
Star Strider 2022 年 9 月 22 日
As always, my pleasure!

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

その他の回答 (0 件)

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by