vector repetition number counting

Hi,I have this vector,x=[2 4 4 1 1].I want the result to be:
1 4
2 1
4 2
4 3
1 5
I tried this small program but it skips the last row in the desired result.Could you find the mistake
d=[];
>> for i=1:4
for j=i+1:5
c=[];
if w(j)== w(i)
c=[c w(j) j];
else
c=[c w(i) i];
end
d=[d;c];
end
end
b=unique(d,'rows')

댓글 수: 4

Azzi Abdelmalek
Azzi Abdelmalek 2014년 4월 6일
What your code is doing?
Azzi Abdelmalek
Azzi Abdelmalek 2014년 4월 6일
Post the expected result
yousef Yousef
yousef Yousef 2014년 4월 7일
the result explains that 1 is repeated 2 times in the positions 4&5 also 2 is not repeated.the position is at 1 4 is repeated 2 times in postions 2&3
Azzi Abdelmalek
Azzi Abdelmalek 2014년 4월 7일
Ok, then what is the result for your example, I'm not asking what the result is explaining, just post the result.

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

답변 (1개)

yousef Yousef
yousef Yousef 2014년 4월 6일

0 개 추천

the result explains that 1 is repeated 2 times in the positions 4&5 also 2 is not repeated.the position is at 1 4 is repeated 2 times in postions 2&3

댓글 수: 2

Azzi Abdelmalek
Azzi Abdelmalek 2014년 4월 6일
편집: Azzi Abdelmalek 2014년 4월 6일
Yousef don't use an answer section to add a comment. Just click on comment on this answer
yousef Yousef
yousef Yousef 2014년 4월 7일
the result explains that 1 is repeated 2 times in the positions 4&5 also 2 is not repeated.the position is at 1 4 is repeated 2 times in postions 2&3

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

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

제품

태그

질문:

2014년 4월 6일

댓글:

2014년 4월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by