Deleting duplicate values in matrix

조회 수: 11 (최근 30일)
kash
kash 2012년 8월 27일
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
Jan
Jan 2012년 8월 27일
Why does the first row vanish?

댓글을 달려면 로그인하십시오.

채택된 답변

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에서 Particle Swarm에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by