MATLAB: Deleting rows in a matrix

deleting rows in a matrix

I want to delete corresponded rows in mother matrix x when x2 have duplicated rows, the following code may explain the goal:
x=[1 0 0 1 1;1 0 1 0 1;1 1 0 0 1]; %mother matrix
y=[5 -2 -1 -1 -1];
x2=[];
for k=1:size(x,1)
x2=[x2;x(k,:)*y'];
end
so this code will give x2=[3;3;2] which means row '1' and row '2' are considered the same and I want to use only one row and delete the other, how can I do that?

Best Answer

[x2u, x2u_idx] = unique(x2, 'stable');
new_x = x(x2u_idx, :);