画直方图函数hist(), 如果没有指定返回参数就是画出直方图,如果指定返回参数,则返回直方图每条数据的数值.
x=normrnd(0,1,1,100);
hist(x);
[n,hx]=hist(x);
str = mat2cell(num2str(n'));
text(hx,n+0.3,str,'Color','r');
x = rand(100,1);
[n,y] = hist(x);
bar(y,n);
for i = 1:length(y)
text(y(i),n(i)+0.5,num2str(n(i)));
end