View License

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

» Watch video

Highlights from
Intersect several arrays

Be the first to rate this file! 10 Downloads (last 30 days) File Size: 1.15 KB File ID: #24835 Version: 1.0

Intersect several arrays


Julia (view profile)


Uses Matlab standard intersect function recursively to return the intersection of several arrays.

| Watch this File

File Information

function [varargout] = intersect_several (varargin)
% function [varargout] = intersect_several (varargin)
% varargout{1} is the intersect vector
% varargout{i>1} are the indices of the various varargin (in their order)

numarr = length(varargin);
intersect_arr = varargin{1};
for i=1:numarr
        intersect_arr= intersect(intersect_arr,varargin{i});
varargout{1} = intersect_arr;
for i=1:numarr
        [intersect_arr, temp,varargout{i+1}]= intersect(intersect_arr,varargin{i});

MATLAB release MATLAB 7.7 (R2008b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (1)
16 Jul 2011 Balazs

Balazs (view profile)

The first cycle can start with 2.

Comment only

Contact us