
ss=1;
Nmin=500/18;  % Minimum points per track

hold off
tr=2;
xx=tpx(sub2ind([MaxBalls Nf],rawtraj(sum(Nptr(1:tr-1))+(1:Nptr(tr))),...
	      rawtime(sum(Nptr(1:tr-1))+(1:Nptr(tr)))));
yy=tpy(sub2ind([MaxBalls Nf],rawtraj(sum(Nptr(1:tr-1))+(1:Nptr(tr))),...
	      rawtime(sum(Nptr(1:tr-1))+(1:Nptr(tr)))));
vx=ddiff(xx,2);
vy=ddiff(yy,2);
ax=ddiff2(xx,2);
ay=ddiff2(yy,2);
tt=0:Nptr(tr)-1;
plot(tt,xx);
hold on

Nppt=max(Nptr);
Nppt=Nf;
Ngptr=Nptr(Nptr>Nmin);
Ngtr=length(Ngptr);
sxx=zeros(Ngtr,Nppt);
syy=zeros(Ngtr,Nppt);
gtr=0;
for tr=1:Ntr
  if (Nptr(tr)>Nmin)
    gtr=gtr+1;
    it=rawtime(sum(Nptr(1:tr-1))+(1:Nptr(tr)));
    xx=tpx(sub2ind([MaxBalls Nf],rawtraj(sum(Nptr(1:tr-1))+(1:Nptr(tr))),it));
    yy=tpy(sub2ind([MaxBalls Nf],rawtraj(sum(Nptr(1:tr-1))+(1:Nptr(tr))),it));
    sxx(gtr,it)=xx;
    syy(gtr,it)=yy;
%    sxx(gtr,[1:it(1) it(end):end])=10*(mean(xx)-90);
%    syy(gtr,[1:it(1) it(end):end])=10*(mean(yy)-90);
    vx=ddiff(xx,2);
    vy=ddiff(yy,2);
    ax=ddiff2(xx,2);
    ay=ddiff2(yy,2);
    tt=0:Nptr(tr)-1;
%    plot(tt.^2,xx-xx(1)-vx(1).*tt);
    plot(tt,xx);
  end 
end

hold off