How to count tha maximum frequency of an element in a matrix/ array?

2 次查看(过去 30 天)
for example if I have an array
x=[1,3,4,2,2,1,1,1,1]
I want to know what is the frequency of each element in the array.
thank you,

回答(1 个)

KSSV
KSSV 2019-1-7
x=[1,3,4,2,2,1,1,1,1] ;
[c,ia,ib] = unique(x) ;
h = hist(ib) ;
[c' h(h>0)']

类别

Help CenterFile Exchange 中查找有关 Graphics Object Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by