How to find the frequency of individual elements in a matrix?
5 次查看(过去 30 天)
显示 更早的评论
How do I find the frequencies of all the elements in the matrix attached and also draw a histogram knowing the frequencies of the elements?
0 个评论
采纳的回答
Dyuman Joshi
2024-4-4
编辑:Dyuman Joshi
2024-4-4
MATLAB has a in-built function for it - histogram, which does both the operations in single command -
s = load('micro2d (2).mat')
vec = s.Expression1(:).';
val = unique(vec);
h = histogram(vec, [val Inf])
%numbers
val
%corresponding frequencies
freq = h.Values
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Histograms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!