How can I delete duplicates in an array, with exceptions?
Show older comments
I have an array which I would like to delete only the 2nd duplicate of a set in an array e.g:
'B1(46)'
'B13(201)'
'B14(201)'
'B14(201)' - delete
'B1(52)'
'B2(52)'
'B2(52)' - delete
'B5(124)'
'B6(124)'
'B6(124)' - delete
'B13(201)'
'B14(201)'
'B14(201)' - delete
My current script (below) will delete all duplicates of 'B14(201)', which is not what I want:
wd=event; % with duplicates
[~,idx]=unique(strcat(wd()),'stable');
newevent=wd(idx); %without duplicates
Thanks
Accepted Answer
More Answers (0)
Categories
Find more on Structures in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!