How to find the frequency of individual elements in a matrix?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Dyuman Joshi
le 4 Avr 2024
Modifié(e) : Dyuman Joshi
le 4 Avr 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Histograms dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!