Binning data into 1000 bins between values
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi all,
I have 75,000 values and I'd like to bin them into 1000 bins between 0.985 and 1.030. Is this possible and if so how?
Regards
Tim
0 commentaires
Réponses (1)
Image Analyst
le 21 Sep 2021
Description
Y = discretize(X,edges) returns the indices of the bins that contain the elements of X. The jth bin contains element X(i) if edges(j) <= X(i) < edges(j+1) for 1 <= j < N, where N is the number of bins and length(edges) = N+1. The last bin contains both edges such that edges(N) <= X(i) <= edges(N+1).
[Y,E] = discretize(X,N) divides the data in X into N bins of uniform width, and also returns the bin edges E.
[Y,E] = discretize(X,dur), where X is a datetime or duration array, divides X into uniform bins of dur length of time. dur can be a scalar duration or calendarDuration, or a unit of time. For example, [Y,E] = discretize(X,'hour') divides X into bins with a uniform duration of 1 hour.
[___] = discretize(___,values) returns the corresponding element in values rather than the bin number, using any of the previous input or output argument combinations. For example, if X(1) is in bin 5, then Y(1) is values(5) rather than 5. values must be a vector with length equal to the number of bins.
2 commentaires
Steven Lord
le 21 Sep 2021
If you also want the counts of how many elements fall into each bin I'd use histcounts with three outputs.
Voir également
Catégories
En savoir plus sur Data Type Conversion 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!