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 comentario

mohd
mohd el 26 de Abr. de 2012
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.

Iniciar sesión para comentar.

 Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 26 de Abr. de 2012

0 votos

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

7 comentarios

Walter Roberson
Walter Roberson el 26 de Abr. de 2012
or length(Xy)
mohd
mohd el 26 de Abr. de 2012
thanks :-)
mohd
mohd el 26 de Abr. de 2012
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 el 26 de Abr. de 2012
Hi Mohd! Your last comment - new question.
Andrei Bobrov
Andrei Bobrov el 26 de Abr. de 2012
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 el 26 de Abr. de 2012
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 el 26 de Abr. de 2012
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]

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Labels and Annotations en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 26 de Abr. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by