specifying bin increments on a histogram
2 views (last 30 days)
I use the code below to create a plots like this with different data sets. I want all plots to have the same scale, i.e. 0 to 90 and -2 to +2.
Not all data sets have data values at the extreme ends of the scales around 80-90 or 1.8-2 for example.
For example if the data in data set only ranges from 0-75 does the code divide the data up into bin intervals of 75/90 or does it create bins in 1 mph increments so bins 76-90 would have no data?
My question is, how can you specify that you want 90 bins a 1 mph increments and you want 40 bins at 0.1 increments from -2 to +2?
% Calculate histogram
nBinsX = 120;
nBinsY = 40;
% Plot histogram
s = get(gca,'child');
zData = get(s,'zData');
'zData' ,zData/length(Data),... % normalize frequency
'EdgeColor' ,0.3*[1 1 1],... % make edges visible at all heights
'CDataMode' ,'auto'); % color tops according to height
title('Velocity VS Acceleration Distribution');
Walter Roberson on 13 Jan 2013
If you want specific bins, then pass in the list of bin centers if you are using hist(), or pass in the list of bin edges if you are using histc()