My X is an array with 110000 numbers from -12 to 12. And I want to plot histogram like this. Can you help me to put a simple logic for this as the code is so long writing like this.
h1 = histogram(x(x>=-12 & x <=-11.9));
hold on;
h1 = histogram(x(x>=-11.9 &x <=-11));
hold on;
h1 = histogram(x(x>=-11 & x <=-10));
hold on;
h1 = histogram(x(x>=-10 & xx <=-9));
hold on;
h1 = histogram(x(x>=-9 & x <=-8));
hold on;
h1 = histogram(x(x>=-8 & x <=-7));
hold on;
h1 = histogram(x(x>=-7& x <=-6));
hold on;
h1 = histogram(x(x>=-6 & x <=-5));
hold on;
h1 = histogram(x(x>=-5&x <=-4));
hold on;
h1 = histogram(x(x>=-4 & x <=-3));
hold on;
h1 = histogram(x(x>=-3 & x <=-2));
hold on;
h1 = histogram(x(x>=-2 & x <=-1));
hold on;
h1 = histogram(x(x>=-1 & x <=0));
hold on;
h1 = histogram(x(x>=0 & x <=1));
hold on;
h1 = histogram(x(x>=1& x <=2));
hold on;
h1 = histogram(x(x>=2 &x <=3));
hold on;
h1 = histogram(x(x>=3 &x <=4));
hold on;
h1 = histogram(x(x>=4& x <=5));
hold on;
h1 = histogram(gx(gx>=5 & x <=6));
hold on;
h1 = histogram(x(x>=6 & gx <=7));
hold on;
h1 = histogram(x(x>=7& x <=8));
hold on;
h1 = histogram(x(x>=9 & x <=10));
hold on;
h1 = histogram(x(x>=10 & x <=11));
hold on;
h1 = histogram(x(x>=11& x <=11.9));
hold on;
h1 = histogram(x(x>=11.9 & x <=12));
hold off;
axis([xmin xmax]);
legend({'-S','-11','-10,'-9','-8','-7','-6','-5','-4','-3','-2','-1','0','1','2','3','4','5','6','7','8','9','10','11','S'});
And my axis doesn't work. And y axis must be in percentage.