function z = findold(x,y)
%
% FINDOLD returns the position of duplicate data in 2 vectors, eg
%         x = [4 1 1 2]; y = [3 1 2]; x = findold(x,y); 
% returns: [2 3 4] (for x values of 1 and 2). 
% Not robust with respect to NaN.
% The order preserved is that of the first argument.
%
% usage:    x = x(findold(x,y));

% Deirdre Byrne, L-DEO 5/12/95 
%
x = x(:); y = y(:);
z = [];
for i = 1:length(y),
  z = [z; find(x == y(i))];
end
z = sort(z);

clear i x y 
return