How to find the frequency of individual elements in a matrix?
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Dyuman Joshi
il 4 Apr 2024
Modificato: Dyuman Joshi
il 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Histograms in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!