MATLAB: Behavior of “unique” with mixed complex numbers

complex numbersMATLABroundunique

I have a large set of complex number that I want to map to an integer grid on the complex plane, removing redundant values. A small subset of the data looks like:
Atest=[-12.9753 - 0.8003i;
-12.9938 - 0.4003i;
-13.0000 + 0.0000i;
-12.9938 + 0.4003i;
12.9938 + 0.4003i;
13.0000 + 0.0000i;
12.9938 - 0.4003i;];
I use round to map to the grid:
Around=round(Atest)
Around =
-13.0000 - 1.0000i
-13.0000 + 0.0000i
-13.0000 + 0.0000i
-13.0000 + 0.0000i
13.0000 + 0.0000i
13.0000 + 0.0000i
13.0000 + 0.0000i
I then use unique to remove the redundant values:
Aunique=unique(Around,'stable')
Aunique =
-13.0000 - 1.0000i
-13.0000 + 0.0000i
-13.0000 + 0.0000i
13.0000 + 0.0000i
Clearly, the result is not unique: the value -13 appears twice. If I apply unique to just the las 6 values of Around (the real values) I obtain the expected results:
Aunique=unique(Around(2:end),'stable')
Aunique =
-13
13
I would appreciate any suggestions for getting the unique values of an array with mixed real and complex values.

Best Answer

Please let me know if I understood correctly your qestion
Atest=[-12.9753 - 0.8003i;
-12.9938 - 0.4003i;
-13.0000 + 0.0000i;
-12.9938 + 0.4003i;
12.9938 + 0.4003i;
13.0000 + 0.0000i;
12.9938 - 0.4003i;];
Around=round(Atest);
A=[real(Around) imag(Around)];
unique(A,'rows')
ans =
-13 -1
-13 0
13 0