>> clear all >> x=round(rand(1,50)*20+2) x = Columns 1 through 19 13 10 11 7 22 10 8 17 15 8 10 20 8 15 17 16 17 6 16 Columns 20 through 38 5 21 4 11 21 3 11 20 6 15 12 12 17 12 18 9 6 18 21 Columns 39 through 50 18 15 18 14 10 18 4 7 5 12 15 19 >> hranice=2:22 hranice = Columns 1 through 19 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Columns 20 through 21 21 22 >> pocet=histc(x,hranice) pocet = Columns 1 through 19 0 1 2 2 3 2 3 1 4 3 4 1 1 5 2 4 5 1 2 Columns 20 through 21 3 1 >> sort(x) ans = Columns 1 through 18 3 4 4 5 5 6 6 6 7 7 8 8 8 9 10 10 10 10 Columns 19 through 36 11 11 11 12 12 12 12 13 14 15 15 15 15 15 16 16 17 17 Columns 37 through 50 17 17 18 18 18 18 18 19 20 20 21 21 21 22 >> h=[4 8 12 22 ] h = 4 8 12 22 >> pocet=histc(x,h) pocet = 9 11 28 1 >> pocet=[pocet(1:end-2) pocet(end-1)+pocet(end)] pocet = 9 11 29 >> bar(h,pocet,'histc') ??? Index exceeds matrix dimensions. Error in ==> makebars at 110 if min(size(y))==1, y = y(ndx); else y = y(ndx,:); end Error in ==> bar>Lbarv6 at 117 [msg,x,y,xx,yy,linetype,plottype,barwidth,equal] = makebars(args{:}); %#ok Error in ==> bar at 44 h = Lbarv6(args{:}); >> bar(h,[pocet 0],'histc') >> sirka=h(2:end)-h(1:end-1) sirka = 4 4 10 >> pocet pocet = 9 11 29 >> vyska=pocet./sirka vyska = 2.2500 2.7500 2.9000 >> bar(h,vyska,) ??? bar(h,vyska,) | Error: Unbalanced or misused parentheses or brackets. >> bar(h,vyska) ??? Error using ==> bar X must be same length as Y. >> h h = 4 8 12 22 >> bar(h,[vyska 0]) >> shg >> bar(h,[vyska 0],'histc') >> shg >> h=0:0.1:1 h = 0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000 >> >> clear >> x=rand(1,5000); >> h=0:0.1:1 h = 0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000 >> hist(x) >> shg >> hist(x,h) >> shg >> s=(h(1:end-1)+h(2:end))/2 s = 0.0500 0.1500 0.2500 0.3500 0.4500 0.5500 0.6500 0.7500 0.8500 0.9500 >> hist(x,s) >> shg >> clear h s >> h=(0:0.05:1) h = Columns 1 through 11 0 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 Columns 12 through 21 0.5500 0.6000 0.6500 0.7000 0.7500 0.8000 0.8500 0.9000 0.9500 1.0000 >> hist(x,h) >> shg >> hist(x) >> shg >> s=(h(1:end)+h(2:end-1))/2; ??? Error using ==> plus Matrix dimensions must agree. >> s=(h(1:end-1)+h(2:end))/2; >> s s = Columns 1 through 11 0.0250 0.0750 0.1250 0.1750 0.2250 0.2750 0.3250 0.3750 0.4250 0.4750 0.5250 Columns 12 through 20 0.5750 0.6250 0.6750 0.7250 0.7750 0.8250 0.8750 0.9250 0.9750 >> hist(x,s) >> shg >> clear all >> x=[2 4 7 10] x = 2 4 7 10 >> a=x(1)-((x(2)-x(1))/2) a = 1 >> b=x(n)+((x(n)-x(n-1))/2) ??? Undefined function or variable 'n'. >> n=length(X) ??? Undefined function or variable 'X'. >> n=length(x) n = 4 >> b=x(n)+((x(n)-x(n-1))/2) b = 11.5000 >> x=[a x b] x = 1.0000 2.0000 4.0000 7.0000 10.0000 11.5000 >> for i=1:n, F(i)=[(2*i-1)/(2*n)]; end >> F=[0 F 1] F = 0 0.1250 0.3750 0.6250 0.8750 1.0000 >> n1=leghth(F) ??? Undefined command/function 'leghth'. >> n1=length(F) n1 = 6 >> for i=1:n1-1, plot([u(i), u(i+1)],[F(i),F(i+1)]),hold on, shg end ??? Undefined command/function 'u'. >> u=x u = 1.0000 2.0000 4.0000 7.0000 10.0000 11.5000 >> for i=1:n1-1, plot([u(i), u(i+1)],[F(i),F(i+1)]),hold on, shg end >> plot(u,F,'+r') >> shg >> interp1(F,u,0.5) ans = 5.5000 >> median(u) ans = 5.5000 >> interp1(u,F,5.5) ans = 0.5000