Home > matutils > findstep.m

findstep

PURPOSE ^

function flag=findstep(v,t,flag,step,maxt)

SYNOPSIS ^

function flag=findstep(v,t,flag,step,maxt)

DESCRIPTION ^

 function flag=findstep(v,t,flag,step,maxt)

 find steps discontinuities in data vector v

 Input:
     v - data vector
     t - time, or x axis value
  flag - if empty will be initialized to zeros
         otherwise it is bad values within v
  step - max step value
  maxt - max time jump

 Output;
  flag - location of bad points

 Michael Loh

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function flag=findstep(v,t,flag,step,maxt)
0002 
0003 % function flag=findstep(v,t,flag,step,maxt)
0004 %
0005 % find steps discontinuities in data vector v
0006 %
0007 % Input:
0008 %     v - data vector
0009 %     t - time, or x axis value
0010 %  flag - if empty will be initialized to zeros
0011 %         otherwise it is bad values within v
0012 %  step - max step value
0013 %  maxt - max time jump
0014 %
0015 % Output;
0016 %  flag - location of bad points
0017 %
0018 % Michael Loh
0019 
0020 if (isempty(flag))
0021   flag=zeros(size(v));
0022 end
0023 
0024 difv=diff(v);
0025 
0026 f=find(abs(difv)<step);
0027 difv(f)=0;
0028 
0029 % ignore everything ignored by ramp and string flaggin
0030 dum=zeros(size(flag));
0031 loc=findramp(v,[],step);
0032 f=find(loc);
0033 difv(f)=0;
0034 
0035 loc=instability(v,t,dum,step,maxt);
0036 f=find(loc);
0037 difv(f)=0;
0038 
0039 % everything is taken care of so all we have left is steps
0040 f=find(abs(difv)>=step);
0041 
0042 %if (length(f)==1)
0043 %  flag(f(1):f(1)+1)=1;
0044 %  difv(f(1))=0;
0045 %  return
0046 %end
0047 
0048 % find 3 consecutive stable points
0049 dif=diff(f);
0050 ff=find(dif>=3);
0051 
0052 for i=1:length(ff)
0053   s=f(ff(i));
0054   e=s+1;
0055   flag(s:e)=1;
0056   difv(s)=0;
0057 end

Generated on Sun 14-Jun-2015 17:12:45 by m2html © 2005