How do I get the average value in my histogram bins

9 views (last 30 days)
I have a large data set of sample points plotted, 2500x2500, and I put these into a histogram using histogram(dist,'BinWidth',60). How can I get the average values of the data in these bins? Or how can I get the values that are in these bins so I can get the average value in each bin?
  1 Comment
Walter Roberson
Walter Roberson on 28 Apr 2019
Do you need the results per row (or per column), or can dist be treated as a vector of values for this purpose (histogram over the entire array simultaneously) ?

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 28 Apr 2019
Try this:
dist = 2000 * rand(2500, 2500);
hObj = histogram(dist,'BinWidth',60)
grid on;
yticks([0:5000:200000]);
% Compute the mean value of the original data.
meanDataValue = mean(dist(:))
% Compute the mean number of counts in each bin.
meanBinCounts = mean(hObj.Values)

More Answers (0)

Community Treasure Hunt

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

Start Hunting!