File Exchange

## INTERSECTALL

version 1.3 (3.05 KB) by

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

Updated

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.

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.

Alle Meije Wink

### Alle Meije Wink (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?

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

peter

### peter (view profile)

can you put an example, thanks