function z = intersect(x, y)
%INTERSECT The set intersectoin of two vectors.
%   z = intersect(x, y) returns the vector z containing all
%   of the elements that are common to both x and y.
%
%   z is the empty vector if there is no element that
%   is in both x and y.

z = [];
for ex = x
    I = find(y == ex);
    if ~isempty(I)
        z = [z ex];
    end
end
