Binning data into 1000 bins between values

4 次查看(过去 30 天)
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

回答(1 个)

Image Analyst
Image Analyst 2021-9-21
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 个评论
Tim Fulcher
Tim Fulcher 2021-9-21
Hi Image Analyst,
thanks for replying. I'll try this and get back to you.
Regards
Tim
Steven Lord
Steven Lord 2021-9-21
If you also want the counts of how many elements fall into each bin I'd use histcounts with three outputs.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by