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일

2 개 추천

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

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 2013년 11월 28일
corrected

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

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 11월 28일

2 개 추천

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

but if i want it in that order itself what should i do....
29 25 27
13 14 19
Elysi Cochin
Elysi Cochin 2013년 11월 28일
thank u all....
Azzi Abdelmalek
Azzi Abdelmalek 2013년 11월 28일
It's in that order

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

카테고리

도움말 센터File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

질문:

2013년 11월 28일

댓글:

2013년 11월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by