Finding the Frequency of Unique Values
19 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Rightia Rollmann
le 13 Août 2016
Modifié(e) : Azzi Abdelmalek
le 13 Août 2016
How to return the frequency of each value in array A? (So, B views there are 3, 1, 4, and 2 of 1, 2, 3, and 4, respectively)
A = [ 1 1 4 3 3 3 3 2 4 1 ]
B = [ 3 1 4 2]
0 commentaires
Réponse acceptée
Azzi Abdelmalek
le 13 Août 2016
Modifié(e) : Azzi Abdelmalek
le 13 Août 2016
A = [ 1 1 4 3 3 3 3 2 4 1 ]
[ii,jj,kk]=unique(A)
freq=accumarray(kk,1)
out=[ii' freq]
%or
freq=hist(A,1:4)
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Startup and Shutdown 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!