Home > NoiseTools > nt_find_triggers.m

nt_find_triggers

PURPOSE ^

tidx=nt_find_triggers(x,threshold,type,guard) - find triggers

SYNOPSIS ^

function tidx=nt_find_triggers(x,threshold,type,guard)

DESCRIPTION ^

tidx=nt_find_triggers(x,threshold,type,guard) - find triggers

  tlist: array of trigger indices

  x: trigger channel waveform
  threshold: trigger threshold
  type: type of trigger ('up' or 'down',guard);
  guard: (samples) dead interval to avoid rebound

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function tidx=nt_find_triggers(x,threshold,type,guard)
0002 %tidx=nt_find_triggers(x,threshold,type,guard) - find triggers
0003 %
0004 %  tlist: array of trigger indices
0005 %
0006 %  x: trigger channel waveform
0007 %  threshold: trigger threshold
0008 %  type: type of trigger ('up' or 'down',guard);
0009 %  guard: (samples) dead interval to avoid rebound
0010 
0011 
0012 if nargin<4 || isempty(guard) ; guard=0; end
0013 if nargin<3 || isempty(type) ; type='up'; end
0014 if nargin<2 threshold=[]; end
0015 if nargin<1; error('!'); end
0016 
0017 if strcmp(type,'down');
0018     tidx=nt_find_triggers(-x,threshold,'up',guard);
0019     return;
0020 end
0021 
0022 if ~strcmp(type,'up'); error('!'); end
0023 
0024 if x ~= x(:); error('trigger waveform should be column vector'); end
0025 
0026 if isempty(threshold); 
0027     threshold=(max(x)+min(x))/2;
0028 end
0029 
0030 xx=x(1:end-1)<threshold & x(2:end)>=threshold;
0031 
0032 
0033 
0034 
0035 tidx=find(xx);

Generated on Mon 30-Jan-2017 18:59:11 by m2html © 2005