View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Multiple or partial INTERSECT function

Join the 15-year community celebration.

Play games and win prizes!

» Learn more

3.0 | 2 ratings Rate this file 1 Download (last 30 days) File Size: 1.73 KB File ID: #30725 Version: 1.1

Multiple or partial INTERSECT function



11 Mar 2011 (Updated )

INTERSECTN allows > 2 inputs and finds partial intersects! Much more flexible than intersect alone!

| Watch this File

File Information

% INTERSECTN functions similarly to INTERSECT, but has some added
% flexibility. For example, if you input three arrays and want to find
% items that are in at least two of them, INTERSECT is incapable of doing
% this, but INTERSECTN will do it.
% Inputs: IN1,IN2,... are cell arrays of strings or numerical vectors.
% MATCHES is a scalar, the number of matches that are required.
% For example, if you have three sets of fruit names, and you want to
% return any fruits that show up in at least two of these sets, use:
% Example:
% fruit{1} = {'apple','banana','cherry','orange'};
% fruit{2} = {'apple','cherry','lemon','tangerine'};
% fruit{3} = {'apple','lemon','lime','peach'};
% fruit{4} = {'apple','lemon','orange','coconut'};
% out = intersectn(fruit{:},4)
% returns: 'apple'
% out = intersectn(fruit{:},3)
% returns: {'apple','lemon'}
% out = intersectn(fruit{:},2)
% returns: {'apple','cherry','lemon','orange'}

MATLAB release MATLAB 7.9 (R2009b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
12 Jun 2013 Ulrik

Ulrik (view profile)

You forgot to state that it requeres the Statistics Toolbox due to the use of "combnk"

13 Mar 2011 peter

peter (view profile)

this is EXACTLY what I was looking ..., thanks

11 Mar 2011 1.1

Updated file description.

Contact us