MATLAB: Unique function not deleting duplicate rows.

matrixrowsunique

attached my matrix "M" and here is my code.
[trash,idx] = unique(M,'rows');
pleb=M(idx,:)
gg=sort(pleb)
When inspecting gg we see that there are still duplicate rows.
I've also tried to do it in different ways, for example;
[~, III, ~] = unique(M,'first','rows'); %removing double points
III = sort(III);
pleb = M(III,:);
gg=sort(pleb);
But they either delete non duplicate data, or delete too few data.
What am I doing wrong?

Best Answer

It is likely that the data are floating point and that they are not actually equal, which confuses many beginners and people not used to working with numeric data. Although what is displayed on the command window might look the same, floating point values can differ at the low end of their significand, so testing for equality (like unique does) does not work.
To understand more about this topic read these:
Alternatively, if the data are strings, trailing spaces are often overlooked by users...