Binning data into 1000 bins between values
2 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Image Analyst
on 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 Comments
Steven Lord
on 21 Sep 2021
If you also want the counts of how many elements fall into each bin I'd use histcounts with three outputs.
See Also
Categories
Find more on Histograms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!