vector repetition number counting

1 Ansicht (letzte 30 Tage)
yousef Yousef
yousef Yousef am 6 Apr. 2014
Kommentiert: Azzi Abdelmalek am 7 Apr. 2014
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 Kommentare
yousef Yousef
yousef Yousef am 7 Apr. 2014
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 am 7 Apr. 2014
Ok, then what is the result for your example, I'm not asking what the result is explaining, just post the result.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

yousef Yousef
yousef Yousef am 6 Apr. 2014
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 Kommentare
Azzi Abdelmalek
Azzi Abdelmalek am 6 Apr. 2014
Bearbeitet: Azzi Abdelmalek am 6 Apr. 2014
Yousef don't use an answer section to add a comment. Just click on comment on this answer
yousef Yousef
yousef Yousef am 7 Apr. 2014
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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by