function [c,ia,ib] = setxor(a,b,flag)
%SETXOR Set exclusive-or for cell array of strings.
%   SETXOR(A,B) when A and B are vectors returns the values that are
%   not in the intersection of A and B.  The result will be sorted.
%
%   [C,IA,IB] = SETXOR(A,B) also returns index vectors IA and IB such
%   that C is a sorted combination of the elements of A(IA) and B(IB).
%
%   See also UNIQUE, UNION, INTERSECT, SETDIFF, ISMEMBER.

%   Copyright (c) 1984-98 by The MathWorks, Inc.
%   $Revision: 1.5 $  $Date: 1998/05/20 15:22:40 $

if nargin>2, error('''rows'' flag not supported for cell arrays.'); end

isrow = ndims(a)==2 & size(a,1)==1 & ndims(b)==2 & size(b,1)==1;

[c,ia,ib] = setxor(char(a),char(b),'rows');
if ischar(a), a = cellstr(a); end
if ischar(b), b = cellstr(b); end
c = sort([reshape(a(ia),size(ia));reshape(b(ib),size(ib))]);

if isrow
  c = c';
  ia = ia';
  ib = ib';
end
