Deleting duplicate values in matrix

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 日

1 投票

[trash,idx] = unique(S(:,1),'stable');
S(idx,:)
Note that only the first column is considered to be the key.

6 件のコメント

kash
kash 2012 年 8 月 27 日
am getting error
Error using cell/unique (line 28) Unrecognized option.
Honglei Chen
Honglei Chen 2012 年 8 月 27 日
編集済み: Honglei Chen 2012 年 8 月 27 日
If it does not solve your issue, please do not accept an answer. The error you see could be due to you are using an older version of MATLAB that does not support 'stable' option.
kash
kash 2012 年 8 月 27 日
ok can u tell how to solve it please am using 2010a
Jan
Jan 2012 年 8 月 27 日
編集済み: Jan 2012 年 8 月 27 日
Omit the "stable", kash. And please be so kind to answer my question: Why does the first row disappear in the output? It is a unique line, so it should be kept according to your explanations.
If using the first row is not enough for your problem, take the time to explain such details. Try unique(S, 'rows') instead.
You've asked 220 questions now and still accept an answer, which does not solve your problem? Surprising. Again I suggest to read, consider and respect the forum rules, which are explained e.g. here: http://www.mathworks.com/matlabcentral/about/answers/
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 件)

カテゴリ

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by