MATLAB: Unique values from from two column

columnmatrixrows

I have a matrix
A=[1 2 3;
2 4 6;
5 3 2;
8 5 4;
6 7 8]
from this matrix, i want that value in first and second column will not get repeated. For eg. in 1st row 2 is in second column and in second row 2 is in 1st column. Please tell me how we can compare these two rows based on first two column and can get only that row whose value in the third column is greater.
Eg:
Output = [ 2 4 6;
8 5 4;
6 7 8]
Only two column (1, 2) will be compared to get the value from third column.

Best Answer

The description of your problem is at best ambiguous.
This produces the result you posted:
Output = A(~any(A(:,[2 3]) == 2, 2),:)
produces:
Output =
2 4 6
8 5 4
6 7 8
It obviously tests on the presence of ‘2’ in the second and third columns, since ‘2’ appears to be important here. Note that in row 2 of your desired ‘Output’ matrix, column 3 is less than the other two elements. I see no pattern other than that expressed in my code.