how to count the numbers

hi there, i have a set of number in my command window. i need to count the numbers. here i attach the illustration for further understand. please help me, thanks..

댓글 수: 1

mohd
mohd 2012년 4월 26일
according to my attach picture. how can i count number with percent. example in attach picture, there are number 1,2,4 and 5.
how can i do to know percent number 1, percent number 2,percent number 4 and percent number 5.

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

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 4월 26일

0 개 추천

out = numel(Xy)
OR so?
out = unique(Xy)

댓글 수: 7

Walter Roberson
Walter Roberson 2012년 4월 26일
or length(Xy)
mohd
mohd 2012년 4월 26일
thanks :-)
mohd
mohd 2012년 4월 26일
according to my attach picture. how can i count number with percent. example in attach picture, there are number 1,2,4 and 5.
how can i do to know percent number 1, percent number 2,percent number 4 and percent number 5.
Andrei Bobrov
Andrei Bobrov 2012년 4월 26일
Hi Mohd! Your last comment - new question.
Andrei Bobrov
Andrei Bobrov 2012년 4월 26일
Xy = [1 1 1 2 2 2 2 4 5 5].'
[out,subs,subs] = unique(Xy)
k = accumarray(subs,ones(numel(subs),1))
out = [out k/sum(k)*100]
mohd
mohd 2012년 4월 26일
wow.. the command is really successful but can you explain a little bit from your command. i'm very interesting to know and learn from you. a million thanks to you andrei bobrov:-)
mohd
mohd 2012년 4월 26일
can you explain this code.
Xy = [1 1 1 2 2 2 2 4 5 5].'
[out,subs,subs] = unique(Xy)
k = accumarray(subs,ones(numel(subs),1))
out = [out k/sum(k)*100]

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

추가 답변 (0개)

카테고리

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

태그

질문:

2012년 4월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by