How can I delete duplicates in an array, with exceptions?
Mostrar comentarios más antiguos
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
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Structures en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!