【ps】可以分段,但是分段时候没去中断的点

clear all
close all
clc;

A=load('outlog.txt');

M=A(1:566,:);
y=zeros(566,2);

y(:,1)=M(:,1);
y(:,2) = medfilt1(M(:,2),5);

seg=zeros(566,1);
th=300;
cnt=0;

if y(1,2)==0
    seg(1)=0;
    seg_cnt=0;
else
    seg(1)=1;
    seg_cnt=1;
end

for i=2:565
    if y(i,2)~=0
        if y(i-1,2)~=0
            if abs(y(i,2)-y(i-1,2))<th
                 seg(i)=seg(i-1);
                 cnt=cnt+1;
            else               
                seg(i)=seg(i-1)+1;                      
                seg_cnt=seg_cnt+1;
            end
           
        else%y i-1 =0

               seg_cnt=seg_cnt+1;
              seg(i)=seg_cnt;
           
        end
 
    end
    y(i,3)=seg(i);
    
end
    
    


for i=1:566
    if seg(i)~=0
        a=mod(seg(i),3);

        if a==0 
         plot(y(i,1),y(i,2),'r.')
         hold on
        else
            if  a==1
               plot(y(i,1),y(i,2),'g.')
              hold on
            else if a==2 
                       plot(y(i,1),y(i,2),'b.')
                       hold on
                end
            end
        end
    else   plot(y(i,1),y(i,2),'y.')
    end
end


  
  

 

posted @ 2016-11-04 11:13  xy123001  阅读(192)  评论(0)    收藏  举报