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!
MATLAB: How do bins in histograms work
binshistogramsplotting
Best Answer