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 1984-2000 The MathWorks, Inc. 
%   $Revision: 1.7 $  $Date: 2000/06/01 04:39:40 $

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

isrow = ~((size(a,1)>1 & size(b,2)<=1) | (size(b,1)>1 & size(a,2)<=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
