Filter löschen
Filter löschen

remove the repeating values in array

2 Ansichten (letzte 30 Tage)
Elysi Cochin
Elysi Cochin am 28 Nov. 2013
Kommentiert: Azzi Abdelmalek am 28 Nov. 2013
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....

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 28 Nov. 2013
Bearbeitet: Andrei Bobrov am 28 Nov. 2013
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 Kommentare
Elysi Cochin
Elysi Cochin am 28 Nov. 2013
But sir i'm getting error.....
??? Error using ==> unique at 34
Unrecognized option.
Error in ==> demoCub at 12
a1 = unique(a','rows','stable')';
Andrei Bobrov
Andrei Bobrov am 28 Nov. 2013
corrected

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 28 Nov. 2013
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),:)'
  3 Kommentare
Elysi Cochin
Elysi Cochin am 28 Nov. 2013
thank u all....
Azzi Abdelmalek
Azzi Abdelmalek am 28 Nov. 2013
It's in that order

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

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

Start Hunting!

Translated by