Deleting duplicate values in matrix
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a dataset in which i have duplicate vaues(same values),i want to delete it as
S={
'' 'c1' 'c2' 'c3'
'p-a' 'pso' 'mpso' 'pso'
'p-a' 'pso' 'mpso' 'pso'
'p-a' 'pso' 'mpso' 'pso'
'k' 'spsp' 'pso' 'mpso'
'y-b' 'pso' 'pso' 'spso'
'y-b' 'pso' 'pso' 'spso'}
i need output as
out={
'p-a' 'pso' 'mpso' 'pso'
'k' 'spsp' 'pso' 'mpso'
'y-b' 'pso' 'pso' 'spso'}
please help
1 Kommentar
Akzeptierte Antwort
Oleg Komarov
am 27 Aug. 2012
[trash,idx] = unique(S(:,1),'stable');
S(idx,:)
Note that only the first column is considered to be the key.
6 Kommentare
Andrei Bobrov
am 27 Aug. 2012
[trash,idx] = unique(S(:,1),'first');
out = S(sort(idx),:);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Particle Swarm finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!