Code covered by the BSD License  

Highlights from
Intersect several arrays

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

Intersect several arrays

by

 

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

| Watch this File

File Information
Description

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});
end
varargout{1} = intersect_arr;
for i=1:numarr
        [intersect_arr, temp,varargout{i+1}]= intersect(intersect_arr,varargin{i});
end
        

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

The first cycle can start with 2.

Contact us