Relative occurance of intersect values
1 view (last 30 days)
Show older comments
Gabriel Stanley on 20 Sep 2022
Commented: Star Strider on 22 Sep 2022
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)));
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 on 20 Sep 2022
The intersect funciton can output the indices of the intersecting elements. See Intersection of Two Vectors and Their Indices for an illustration.
More Answers (0)
Find more on Solver Outputs and Iterative Display in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!