xs=0.5; ys=0.5; r=0.1; th=2.5; n=9; tc=[0.08, 0.08, 0.1, 0.15, 0.20, 0.15, 0.10, 0.20]; a=10; for k=1:n; x(k)=xs+r*cos(th*(k-1)/(n-1)); y(k)=ys+r*sin(th*(k-1)/(n-1)); end % pospeski ax(1)=sign(x(2)-x(1))*a; ax(n)=sign(x(n)-x(n-1))*a; % "casi pospeskov in pojemkov tx(1)=tc(1)-sqrt(tc(1)^2 + 2 * (x(2)-x(1))/ax(1)); tx(n)=tc(n-1)-sqrt(tc(n-1)^2 + 2 * (x(n)-x(n-1))/ax(1)); % hitrosti vx(1)=(x(2)-x(1))/(tc(1)-tx(1)/2); vx(n-1)=(x(n)-x(n-1))/(tc(n-1)-tx(n)/2); for k=2:(n-2); vx(k)=(x(k+1)-x(k))/tc(k); end; % vmesni cleni for k=2:(n-1); ax(k)=sign(vx(k)-vx(k-1)) * a; end; % vmesni casi for k=2:(n-1); tx(k)=(vx(k)-vx(k-1))/ax(k); end; % "casi enakomernega gibanja txe(1)=tc(1)-tx(1)-tx(2)/2; txe(n-1)=tc(n-1)-tx(n)-tx(n-1)/2; for k=2:(n-2); txe(k)=tc(k)-tx(k+1)/2-tx(k)/2; end; % izracun xizr(1)=x(1); xizr(2)=xizr(1)+ax(1)*tx(1)^2/2+vx(1) .... *(txe(1)+tx(1)/2)+(tx(2)/2)^2*ax(2)/2; for k=3:(n-1); xizr(k)=xizr(k-1)+ax(k-1)*(tx(k-1)/2)^2/2+vx(k-1)* ... (txe(k-1)+tx(k-1)/2)+(tx(k)/2)^2*ax(k)/2; end; xizr(n)=xizr(n-1)+ax(n-1)*(tx(n-1)/2)^2/2+vx(n-1)* ... (txe(n-1)+tx(n-1)/2)+(tx(n))^2*ax(n)/2; %napaka napx=(x-xizr)./x; % pospeski ay(1)=sign(y(2)-y(1))*a; ay(n)=sign(y(n)-y(n-1))*a; % casi pospeskov in pojemkov ty(1)=tc(1)-sqrt(tc(1)^2 + 2 * (y(2)-y(1))/ay(1)); ty(n)=tc(n-1)-sqrt(tc(n-1)^2 + 2 * (y(n)-y(n-1))/ay(1)); % hitrosti vy(1)=(y(2)-y(1))/(tc(1)-ty(1)/2); vy(n-1)=(y(n)-y(n-1))/(tc(n-1)-ty(n)/2); for k=2:(n-2); vy(k)=(y(k+1)-y(k))/tc(k); end; % vmesni cleni for k=2:(n-1); ay(k)=sign(vy(k)-vy(k-1)) * a; end; % vmesni casi for k=2:(n-1); ty(k)=(vy(k)-vy(k-1))/ay(k); end; % casi enakomernega gibanja tye(1)=tc(1)-ty(1)-ty(2)/2; tye(n-1)=tc(n-1)-ty(n)-ty(n-1)/2; for k=2:(n-2); tye(k)=tc(k)-ty(k+1)/2-ty(k)/2; end; % izracun yizr(1)=y(1); yizr(2)=yizr(1)+ay(1)*ty(1)^2/2+vy(1)*(tye(1)+ty(1)/2)+(ty(2)/2)^2*ay(2)/2; for k=3:(n-1); yizr(k)=yizr(k-1)+ay(k-1)*(ty(k-1)/2)^2/2+vy(k-1) ... *(tye(k-1)+ty(k-1)/2)+(ty(k)/2)^2*ay(k)/2; end; yizr(n)=yizr(n-1)+ay(n-1)*(ty(n-1)/2)^2/2+vy(n-1)... *(tye(n-1)+ty(n-1)/2)+(ty(n))^2*ay(n)/2; %napaka napy=(y-yizr)./y;