MATLAB: Value swapping

find

Hello,
I have a matrix
x =
7 8
7 13
1 7
3 7
i want to search all 7 and shift to the first column and the corresponding value to the other coloumn, like
x =
7 8
7 13
7 1
7 3

Best Answer

x(x(:,2)==7,:) = fliplr(x(x(:,2)==7,:))