How to find the frequency of individual elements in a matrix?
6 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Dyuman Joshi
on 4 Apr 2024
Edited: Dyuman Joshi
on 4 Apr 2024
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 Comments
More Answers (0)
See Also
Categories
Find more on Histograms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!