a=round(rand(1,35)*17+3) a = Columns 1 through 13 5 17 10 18 15 15 9 6 6 6 10 18 11 Columns 14 through 26 17 11 11 11 10 18 3 8 4 15 14 20 12 Columns 27 through 35 10 6 14 15 9 3 10 16 16 aa=sort(a) aa = Columns 1 through 13 3 3 4 5 6 6 6 6 8 9 9 10 10 Columns 14 through 26 10 10 10 11 11 11 11 12 14 14 15 15 15 Columns 27 through 35 15 16 16 17 17 18 18 18 20 hranice=[0 8 14 17 20] hranice = 0 8 14 17 20 pocetnost=histc(aa,hranice) pocetnost = 8 13 8 5 1 %ohranicenie musi byt od nuly po max prvok!!! %bez posunu intervalov do stredu bar(hranice,pocetnost) bar(hranice,pocetnost,'histc') shg %chyba lebo som nepriratal poslednupocetnost k predoslemu inervalu pocetnost=[pocetnost(1:(end-2)) pocetnost(end-1)+pocetnost(end)] pocetnost = 8 13 8 6 %spravne zobrazenie bar(hranice,[pocetnost 0],'histc') shg %posunute stredy stredy=(hranice(1:(end-1))+hranice(2:(end)))/2 stredy = 4.0000 11.0000 15.5000 18.5000 bar(stredy, pocetnost) shg % spravne bar(stredy, pocetnost,'histc') shg