tomwalters@0: function detect = DetectFun(velocity) tomwalters@0: % function detect = DetectFun(velocity) tomwalters@0: % a somewhat-compressing HWR. tomwalters@0: tomwalters@0: negate = 0; % depending on filterbank parameters, one or other might "thump" tomwalters@0: if negate tomwalters@0: velocity = -velocity; tomwalters@0: end tomwalters@0: tomwalters@0: velocity(velocity < 0) = 0; tomwalters@0: a = 0.25; % limiting slope, relative to 1 where it starts tomwalters@0: detect = min(1, velocity); tomwalters@0: detect = a*velocity + (1-a)*(detect - (detect.^3)/3); tomwalters@0: tomwalters@0: % test it this way: tomwalters@0: %plot(-1:.1:2, DetectFun(-1:.1:2))