Centering histogram bins and setting percentage range in Matlab

余生长醉 提交于 2019-11-29 16:20:38

Start by using hist with your expected centers. Then use bar and xlabel to display the histogram with the y axis the way you want:

dat = randi(15,100,1);
centers = 1:15;
counts = hist(dat,centers);
pcts = 100 * counts / sum(counts);
bar(centers,counts)
ylabel('%')
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!