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.

 Réponse acceptée

Oleg Komarov
Oleg Komarov le 8 Mai 2011

0 votes

c = histc(A(:),unique(A))

3 commentaires

Mohammad Golam Kibria
Mohammad Golam Kibria le 8 Mai 2011
sorry, here frequency of 1 means no of 1 in the matrix
similarly frequency of 2 means no of 2 in the matrix
Oleg Komarov
Oleg Komarov le 8 Mai 2011
Didn't notice the ; in your A. Edited above.
Teja Muppirala
Teja Muppirala le 8 Mai 2011
A similar alternative:
[counts,values] = hist(A(:),unique(A))

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Language Fundamentals dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by