remove the repeating values in array

1 view (last 30 days)
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....

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 28 Nov 2013
Edited: Andrei Bobrov on 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 Comments
Elysi Cochin
Elysi Cochin on 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')';

Sign in to comment.

More Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 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 Comments

Sign in to comment.

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!