
function z = intersec(x,y)

%    usage:  z = intersec(x,y)
%  purpose:  to form the intersection of the 'sets' x and y

%   extern:  union
%   author:  risto rauhala, Tampere University of Technology, Finland

z = sort([union(x,[]) union(y,[])]); n = length(z);

if n > 0
   z = z([0 ~(z(2:n)-z(1:n-1))]);
end
