I have got a sequence with size of 1 million. I want to plot a pdf for this sequence by putting same values together. Does anyone have any idea?

댓글 수: 2

Azzi Abdelmalek
Azzi Abdelmalek 2014년 4월 4일
putting same values together: What do you mean?
EEE
EEE 2014년 4월 4일
Thank you for your comment. For example, a sequence [1 1 1 1 1 1 2 2 2 2 3 3 3], so there are 5 1s, 4 2s and 3 3s. I want cumulate them so 1 has a magnitude of 5 and 2 has a magnitude of 4 and 3 has a magnitude of 3. Is this clear?

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

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 4월 4일

0 개 추천

A=[1 1 1 1 1 1 2 2 2 2 3 3 3]
[a,b,c]=unique(A)
out=accumarray(c,A') % corresponding to a'
[a' out]

추가 답변 (1개)

Image Analyst
Image Analyst 2014년 4월 4일

0 개 추천

A million elements is not large at all - just a very small fraction of the number of elements in an ordinary digital image for example. It sounds like you just want the histogram. If you have all integers:
data = [1 1 1 1 1 1 2 2 2 2 3 3 3]
edges = 1 : max(data(:));
counts = histc(data, edges)
counts =
6 4 3
Though perhaps I misunderstood because you have 5,4,3 instead of 6,4,3. Can you explain how you got the 5? Did you just ignore the first element or something???

카테고리

도움말 센터File Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

질문:

EEE
2014년 4월 4일

답변:

2014년 4월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by