How to find the frequency of individual elements in a matrix?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Prince
am 4 Apr. 2024
Bearbeitet: Dyuman Joshi
am 4 Apr. 2024
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 Kommentare
Akzeptierte Antwort
Dyuman Joshi
am 4 Apr. 2024
Bearbeitet: Dyuman Joshi
am 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Histograms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!