To change bin size on a histogram in MATLAB, you can use the histogram
function and specify the bin edges.
Here's an example code snippet that creates a histogram and sets the bin size to 0.5:
main.m98 chars5 lines
In this code, randn(1000,1)
creates a random data with 1000 elements. min(data)
and max(data)
determine the minimum and maximum values of the data. Finally, we specify the bin size as binSize = 0.5
and compute the edges using min(data):binSize:max(data)
. Then, we create a histogram using these edges in the histogram
function.
You can adjust the bin size by changing the binSize
variable to your desired value.
gistlibby LogSnag