how I can calculate average of some histograms

2 views (last 30 days)
would you please guide me how I can calculate average of some histograms and then show it on the same histogram? thanks

Accepted Answer

Walter Roberson
Walter Roberson on 27 Jan 2016
If the counts are stored in counts1, counts2, counts3, counts4, counts5, and the bin centers or bin edges were fixed (not just the number of bins), then
mean_counts = mean([counts1(:), counts2(:), counts3(:), counts4(:), counts5(:)], 2);
If necessary, calculate the bin centers into bin_centers from the bin edges:
bin_centers = (bin_edges(1:end-1) + bin_edges(2:end)) / 2;
Then to add to the plot in the current axes,
hold on
relative_width = 1;
bar(bin_centers, mean_counts, relative_width);

More Answers (0)

Community Treasure Hunt

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

Start Hunting!