Home > data-analysis > manip > cevent > cevent_next_certain_event.m

cevent_next_certain_event

PURPOSE ^

cevent_next_certain_event(time,event_type, cevent, inside_ok);

SYNOPSIS ^

function [a_cevent]= cevent_next_certain_event(time,event_type, cevent, inside_ok);

DESCRIPTION ^

 cevent_next_certain_event(time,event_type, cevent, inside_ok);
 give a timestamp, find a next single event in a cevent/event that
 matches with a certain event type. 
 inside_ok: 1 will return the "current" event if TIME is inside an event,
               otherwise will return the next event
            0 no overlap

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function  [a_cevent]= cevent_next_certain_event(time,event_type, cevent, inside_ok);
0002 % cevent_next_certain_event(time,event_type, cevent, inside_ok);
0003 % give a timestamp, find a next single event in a cevent/event that
0004 % matches with a certain event type.
0005 % inside_ok: 1 will return the "current" event if TIME is inside an event,
0006 %               otherwise will return the next event
0007 %            0 no overlap
0008 %
0009 a_cevent = [];
0010 % find the one in the middle
0011 if inside_ok == 1 
0012     [list] = find((cevent(:,2) >= time) & (cevent(:,1) <= time));
0013     if ~isempty(list) && (cevent(list(end),3) == event_type)
0014         a_cevent = cevent(list(end),:);
0015         return;
0016     end;
0017 end;
0018 
0019 % else find the one after
0020 [list] = find(cevent(:,1) >= time);
0021 next_list = sortrows(cevent(list,:),1);
0022 next_index = find(next_list(:,3) == event_type);
0023 if ~isempty(next_index)
0024     a_cevent = next_list(next_index(1),:);
0025 end;
0026 
0027 
0028 
0029 
0030

Generated on Tue 23-May-2017 20:00:55 by m2html © 2005