remove the repeating values in array

1 次查看(过去 30 天)
i have an array with 2 rows 9 columns values
29 29 29 29 25 25 29 29 27
13 13 13 13 14 14 13 13 19
i wanted to remove the repeating values and get the output as
29 25 27
13 14 19
what code should i write to remove the repeated values?? please do reply....

采纳的回答

Andrei Bobrov
Andrei Bobrov 2013-11-28
编辑:Andrei Bobrov 2013-11-28
a = [ 29 29 29 29 25 25 29 29 27;
13 13 13 13 14 14 13 13 19];
[ii,ii] = unique(a','rows','first')
out = a(:,sort(ii));
  2 个评论
Elysi Cochin
Elysi Cochin 2013-11-28
But sir i'm getting error.....
??? Error using ==> unique at 34
Unrecognized option.
Error in ==> demoCub at 12
a1 = unique(a','rows','stable')';

请先登录,再进行评论。

更多回答(1 个)

Azzi Abdelmalek
Azzi Abdelmalek 2013-11-28
a=[29 29 29 29 25 25 29 29 27;
13 13 13 13 14 14 13 13 19];
b=a'
[ii,jj]=unique(a','rows')
out=b(sort(jj),:)'

类别

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

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by