What you're describing sounds like a bar chart rather than a histogram. 1000 bars is quite a lot of bars.
data = logical(randi(2,100,100,100)-1);
count = squeeze(sum(data,[1,2]));
bar(count)
histogram('BinEdges',1:101,'BinCounts',count)
How do bins in histograms work?
Suppose you have a bunch of random data between 0 and 100 and you want to know how many values there are between 0:5, 5:10, 10:15, ..., 95:100. The histogram function (or the histcounts function) will sort your data into those bins and count the number of points within each bin.
In your case, you're not really working with bins. You want to know the number of 1-values on each layer of your 3D array. If you ask the histrogram function for 1000 bins, it will see that your data (the 1-counts) range from 0 to 10^5 and it will divide that range into 1000 parts. That's not what you want. You already know the "bins" (1,2,3,...,1000, which aren't really bins). Does that make more sense?
0 Comments
Sign in to comment.