Code covered by the BSD License

Highlights from INTERSECTALL

Be the first to rate this file! 1 Download (last 30 days) File Size: 3.05 KB File ID: #38968 Version: 1.3

INTERSECTALL

Mehmet Suzen (view profile)

09 Nov 2012 (Updated )

Given set of sets, produce all possible intersections for each set or all sets at once.

File Information
Description

Simple function INTERSECTALL efficiently returns intersections of given set of sets, computed combinatorially. It returns cell array of vectors of indices of a set that have instersection to any other set and a vector that gives number of intersections for each set. INTERSECTALLSET is much simpler, it returns the values of the set which are members of all sets.

Required Products MATLAB
MATLAB release MATLAB 7.14 (R2012a)
29 Aug 2013 Mehmet Suzen

Mehmet Suzen (view profile)

@Alle Meije,

Thanks for the feedback. I have added one more utility, called INTERSECTALLSET. It does what you need. Also, I've updated the description, hoping that now it is clear what INTERSECTALL produces.

Comment only
28 Aug 2013 Alle Meije

Alle Meije (view profile)

Hi, thanks for this - but I don't understand your example.

I have a number of indices found in different maps say:

ind{1} = [ 1 3 4 5 6 7 9 ];
ind{2} = [ 1 2 3 6 7 8 9 ];
ind{3} = [ 2 3 4 5 6 7 8 ];

what I expect to find in the intersection of these 3 maps are the indices that are in all sets, i.e.
[3 6 7]. Is it possible to get that with your code?

Comment only
09 Nov 2012 Mehmet Suzen

Mehmet Suzen (view profile)

Just uploaded a new version with the following example, hope it helps:

vecSets = {[11, 12, 22, 14], [11, 15, 17, 22, 33], [ 17, 25, 14] }
[indexSet, numAllintersect] = intersectAll(vecSets);
indexSet{1}
ans =
1 3 4
indexSet{2}
ans =
1 3 4
indexSet{3}
ans =
1 3
numAllintersect
3
3
2

Comment only
09 Nov 2012 peter

peter (view profile)

can you put an example, thanks

Comment only
12 Nov 2012 1.1