how do bins in histograms work?
Show older comments
Hello! I am working on a homework assignment where we are given a 1000x1000x1000 logical matrix and we want to create a histogram showing the number of ones in each layer of the matrix. I went through, indexed each of the 1000 layers and counted the number of zeros, but I am now having trouble with the bins on my histogram. I want to plot it so that the x axis has a bar for each of the 1000 layers and the y axis shows how many 1s were in each layer. When I specify the number of bins as 1000, my X axis goes from (0 to 2.5)*10^5 and my y axis goes from 0 to 50, and when I don't specify the bins at all by x axis goes from (0 to 3)*10^5 and my y axis goes from 0 to 900. Is there something wrong with my code that counts the ones, or am I misunderstanding something about histograms and bins? Is what I want to do with my histogram even possible? Thank you!
Accepted Answer
More Answers (0)
Categories
Find more on Data Distribution Plots 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!