Code covered by the BSD License  

Highlights from
Intersect several arrays

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

Intersect several arrays

by Julia

 

24 Jul 2009

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  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
16 Jul 2011 Balazs

The first cycle can start with 2.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
matrix Julia 24 Jul 2009 11:03:58
intersect Julia 24 Jul 2009 12:41:48
common Julia 24 Jul 2009 12:41:48
intersection Julia 24 Jul 2009 12:41:48
intersect Ahmed Ben Saïda 09 Feb 2010 05:49:56

Contact us at files@mathworks.com