frequency determination

1 次查看(过去 30 天)
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.

采纳的回答

Oleg Komarov
Oleg Komarov 2011-5-8
c = histc(A(:),unique(A))
  3 个评论
Oleg Komarov
Oleg Komarov 2011-5-8
Didn't notice the ; in your A. Edited above.
Teja Muppirala
Teja Muppirala 2011-5-8
A similar alternative:
[counts,values] = hist(A(:),unique(A))

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by