 r=rand(1,500);a=2;b=10;
x=(b-a)*r+a;

[n,xg]=hist(x,16);
 yn=n/max(n)/(b-a);
 bar(xg,yn)
 