Deleting duplicate values in matrix

1 次查看(过去 30 天)
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

采纳的回答

Oleg Komarov
Oleg Komarov 2012-8-27
[trash,idx] = unique(S(:,1),'stable');
S(idx,:)
Note that only the first column is considered to be the key.
  6 个评论
Andrei Bobrov
Andrei Bobrov 2012-8-27
[trash,idx] = unique(S(:,1),'first');
out = S(sort(idx),:);
kash
kash 2012-8-29
Thanks andrei and Jan by mistake i clicked Accepy the answer button

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by