MATLAB: Finding similar values in matrices and removing them

matricesmatrixmatrix arraymatrix manipulationx y values

I have some matrices and want to find values that are similar in them and then create new matrices without them.
For example, if I have
one set of x1,y1 values (1,10) (2,20) (3,30) (4,40) (5,50)
second set of x2,y2 values (100,901) (200,902) (300,903) (2,904)
These values are present in different matrices( rows1, columns1) and (rows2, columns2) I want the program to automatically recognize that the x value 2 is shared between the two sets and I want it to remove the whole ordered pair of (2,20) and (2,904) from both sets. It doesn't matter if the y value is shared, only a common x value should signal it to remove the entire ordered pair from both sets.

Best Answer

Assuming that the x values are not repeated in each matrix, and assuming that your weird notation (please use valid matlab notation to avoid ambiguity) means that x is column1 and y is column2, then:
[~, rows1, rows2] = setxor(matrix1(:, 1), matrix2(:, 1));
matrix1 = matrix1(rows1, :);
matrix2 = matrix2(rows2, :);