
REstarA = [2400    -1800];
nR = length(REstarA);

Bo=1000;

    lfile = sprintf('Collected_Surface_Extract_RE%d_Bo%d',REstarA(1),Bo);
    load(lfile)


nt = length(time);
Xmax = nan*ones(nt,nR);
Ymax = nan*ones(nt,nR);
Xmax2 = nan*ones(nt,nR);
Ymax2 = nan*ones(nt,nR);
Xmaxslope  = nan*ones(nt,nR);
max_slope  = nan*ones(nt,nR);
Xminslope  = nan*ones(nt,nR);
min_slope  = nan*ones(nt,nR);

Nxbar = nan*ones(nt,nR);
Nxbar_denoise = nan*ones(nt,nR);
istart = 200; % time=0.5
iend = 358; % t=18.3
% index 280  => t=14.00
% index 390  => t=18.30
for k=1:nR,
    REstar = REstarA(k);
    lfile = sprintf('Collected_Surface_Extract_RE%d_Bo%d',REstar,Bo);
    load(lfile)
  figure(k),clf
  for i=1:390, %10:390, %280:280, %:nt,
  
      A = SURF{i};
      [ymax,imax]=max(A.Ys);
      Ymax(i,k)=ymax;  Xmax(i,k)=A.Xs(imax);
      ii = find((A.Xs> Xmax(i,k)-6)&(A.Xs<Xmax(i,k)+6));
      
%       [fit1,G,O] = fit( A.Xs(ii), A.Ys(ii),'smoothingspline','SmoothingParam',0.99);
%       YY=feval(fit1,A.Xs(ii));
%       [dYdX,d2YdX2] = differentiate(fit1,A.Xs(ii));
% 
%       [Ymax2(i,k),imax2]=max(YY);
%       Xmax2(i,k) = A.Xs(ii(imax2));
%       
%        [mxslope,imaxs] = max(dYdX);
%        [minslope,imins] = min(dYdX);      
%        max_slope(i,k)= mxslope;
%        min_slope(i,k)= minslope;
%        Xmaxslope(i,k) = A.Xs(ii(imaxs));
%        Xminslope(i,k) = A.Xs(ii(imins));

      ii = find(A.Xs < 10 );
      ymax = 1.2* max(abs(A.Ys(ii)));
      plot(A.Xs,A.Ys,'r.'),grid
      title(sprintf('RE=%d, Bo=%d, doing t=%.2f',REstar,Bo,time(i)))
      axis([-0.1 10  -ymax ymax])
      xlabel('x')
      ylabel('y')
      drawnow
  end;

end;

%clear SURF A
%save SurfaceExtract1000.mat

