function flag=findramp(v,flag,ramp) find ramps in the data vector v Input: v - data vector flag - if empty will be initialized to zeros otherwise it is bad values within v ramp - ramp threshold. or maximum rate of change (slope) Output; flag - location of bad points Michael Loh
0001 function flag=findramp(v,flag,ramp) 0002 0003 % function flag=findramp(v,flag,ramp) 0004 % 0005 % find ramps in the data vector v 0006 % 0007 % Input: 0008 % v - data vector 0009 % flag - if empty will be initialized to zeros 0010 % otherwise it is bad values within v 0011 % ramp - ramp threshold. or maximum rate of change (slope) 0012 % 0013 % Output; 0014 % flag - location of bad points 0015 % 0016 % Michael Loh 0017 0018 if (isempty(flag)) 0019 flag=zeros(size(v)); 0020 end 0021 0022 difv=diff(v); 0023 0024 f=find(abs(difv)<ramp); 0025 difv(f)=0; 0026 0027 % get sign info 0028 phs=sign(difv); 0029 0030 % find consecutive signs 0031 % first do positive 0032 [s,e]=group(phs>0); 0033 0034 ramp=find((e-s)>=1); 0035 for i=1:length(ramp) 0036 flag(s(ramp(i))+1:e(ramp(i)))=1; 0037 end 0038 0039 % now do neg 0040 [s,e]=group(phs<0); 0041 0042 ramp=find((e-s)>=1); 0043 for i=1:length(ramp) 0044 flag(s(ramp(i))+1:e(ramp(i)))=1; 0045 end