MATLAB: How to calculate width and height of histogram

heighthistogramwidth

I have an image data, whose histogram , i am calculating through hist command(not imhist) and then i get two parameters: one centroid of the bin, and another is no. of pixels in a bin, i want to calculate height and width of each bin. Pls help

Best Answer

I'm not sure I understand that information is returned by hist()
X = randn(100,1);
[N,bincntr] = hist(X);
Now you know the count in each bin and the bin centers.
To find the boundaries, you can just do
Dx = mean(diff(bincntr));
Now you get the intervals as [bincntr-Dx/2, bincntr+Dx/2]
They are all of width Dx and height equal to the corresponding N