%% Union of Rows in Two Matrices
% Define two matrices with a row in common.

A = [2 2 2; 0 0 1];
B = [1 2 3; 2 2 2; 2 2 2];

%
% Find the combined rows of A and B, with no repetition, as well as the index vectors ia and ib.

[C,ia,ib] = union(A,B,'rows')

% The rows of C are the combined rows of A(ia,:) and B(ib,:).
% Copyright 2012 The MathWorks, Inc.