frequency determination

1 visualización (últimos 30 días)
Mohammad Golam Kibria
Mohammad Golam Kibria el 8 de Mayo de 2011
Hi I have a matrix as follows:
A=[1 2 3; 2 3 2; 1 2 3]
I need to determine the frequency of the matrix value. i.e.
the frequency of 1 is 2 the frequency of 2 is 4 the frequency of 3 is 3
How to do this easily.

Respuesta aceptada

Oleg Komarov
Oleg Komarov el 8 de Mayo de 2011
c = histc(A(:),unique(A))
  3 comentarios
Oleg Komarov
Oleg Komarov el 8 de Mayo de 2011
Didn't notice the ; in your A. Edited above.
Teja Muppirala
Teja Muppirala el 8 de Mayo de 2011
A similar alternative:
[counts,values] = hist(A(:),unique(A))

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by