Reputation: 13
I would like to delete all the repeated rows ignoring the contents of the 2nd column
I have used this code : x = unique(x,'rows');
without success;
Thank you for your help.
A=
1 x 10 4
1 x 10 4
1 x 10 4
2 x 20 5
2 x 15 5
3 x 30 6
4 x 50 7
4 x 50 7
5 x 60 8
5 x 60 8
5 x 65 9
Result
A =
1 x 10 4
2 x 20 5
2 x 15 5
3 x 30 6
4 x 50 7
5 x 60 8
5 x 65 9
Upvotes: 1
Views: 57
Reputation: 112669
Use the multiple-output version of unique
to get the row indices:
[bb ii jj] = unique(A(:,[1 3:end]),'rows');
result = A(ii,:);
This is essentially the same as @RobertP.'s answer, which came 6 seconds earlier :-)
Upvotes: 0
Reputation: 14939
I think this should work:
[~, idx] = unique(A(:,[1 3 4]),'rows')
B = A(idx,:)
Upvotes: 1