how to count the numbers

1 次查看(过去 30 天)
mohd
mohd 2012-4-26
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
out = numel(Xy)
OR so?
out = unique(Xy)
  7 个评论
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 个)

类别

Help CenterFile Exchange 中查找有关 Sample Class Implementations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by