File Exchange

image thumbnail

Intersect several arrays

version 1.0 (1.15 KB) by

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

2 Downloads

Updated

View License

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

Comments and Ratings (1)

Balazs

Balazs (view profile)

The first cycle can start with 2.

MATLAB Release
MATLAB 7.7 (R2008b)

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

» Watch video