How does one plot a histogram from the histogram counts?
显示 更早的评论
I have produced an array of counts, specifically produced with:
histcounts
the reason I do this is because storing the actual data is way to expensive in terms of storage. So on the fly I update my histcount. Now that I have them, how do I plot the histogram?
----
demo code:
W_hist_counts = zeros(1,D);
for i=2:iter+1
W = get_vector_we_want_stats(W)
%
W_hist_counts = W_hist_counts + histcounts(W,nbins);
end
----
回答(2 个)
the cyclist
2017-3-27
0 个投票
4 个评论
Brando Miranda
2017-3-27
Star Strider
2017-3-27
If the edges are regularly spaced, this is what I do to create a vector of centers for the bar plot:
e = 1:5 % ‘Edges’ Vector
xt = e(1:end-1)+mean(diff(e))/2 % ‘Midpoint’ Vector
e =
1 2 3 4 5
xt =
1.5 2.5 3.5 4.5
Brando Miranda
2017-3-27
the cyclist
2017-3-28
I assume you want to normalize to an overall sum of 1. You should just be able to plot
W_hist_counts/sum(W_hist_counts)
to normalize, right?
Image Analyst
2017-3-27
0 个投票
histogram() can plot the histogram data (counts vs values) if you pass in the counts and values instead of the data. Otherwise you can do it manually with bar().
类别
在 帮助中心 和 File Exchange 中查找有关 Histograms 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!