vector repetition number counting
2 次查看(过去 30 天)
显示 更早的评论
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
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
2014-4-6
2 个评论
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!