% clean up data for msft34(new version)
load msft34.txt;
[m, n] = size(msft34);

 for j=1:m-1,
        c(1)=1;
         if msft34((j+1),1)== msft34(j,1) & msft34((j+1),2)== msft34(j,2) & msft34((j+1),3)== msft34(j,3), 
            c(j+1)=c(j);
         else
            c(j+1)=c(j)+1;
         end; 
  end;       
  msft34=[c(:) msft34(:,4:8)];
  
  for j=1: max(msft34(:,1)),
     Time = [10, 0];
     temp=msft34(find(msft34(:,1)==j),1:6);
     
     
     for i=1:73,
        k=73*(j-1)+i;
        [p,q]=size(temp);
        ss=0;
        for l=1:p, 
              tt(l)=temp(l,2)*3600+ temp(l,3)*60+ temp(l,4);
                  
       if tt(l)<=(Time(1)*3600 + Time(2)*60) & temp(l, 5) ~= 0 & temp(l, 6) ~= 0 & abs((temp(l, 6)-temp(l, 5)))<=2,
          msft34m(k,1:3)=[temp(l,1) temp(l,5:6)];
          ss=ss+1;
                  
       elseif tt(l)>(Time(1)*3600 + Time(2)*60),
          break;
       end;
           
      end;
   if ss==0,
      msft34m(k,1:3)=msft34m(k-1,1:3);
   end;

   
      if Time(2)<= 50,
      Time(2) = Time(2) + 5;
      else
      Time(1) = Time(1) + 1;
      Time(2) = 0;     
      end;
   end;
end;
save msft34m msft34m;
