How do I get the average value in my histogram bins
9 views (last 30 days)
Show older comments
Brendan Cornelison
on 27 Apr 2019
Answered: Image Analyst
on 28 Apr 2019
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
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) ?
Accepted Answer
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)
0 Comments
More Answers (0)
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!