The problem is with this expression in the if statement:
if abs(matrix10(i,j) - matrix10(i,:)) >= 2
The left hand side is a vector but right side is a scalar -- which means that the condition is only met if all 3 differences exceed 2. What is the actual condition you want to check? If it is whether the total sum of differences exceeds 2, then you need to change the statement to:
if sum(abs(matrix10(i,j) - matrix10(i,:))) >= 2
Or it could be something else depending on what your condition actually is.