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

cevent_longest_match

PURPOSE ^

return the longest event in a cevent list that matches the category target

SYNOPSIS ^

function [dur] = cevent_longest_match(data, target)

DESCRIPTION ^

 return the longest event in a cevent list that matches the category target
 If used without target, return the long duration among any categories
 usage: cevent_longest_match(data, target)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [dur] = cevent_longest_match(data, target)
0002 % return the longest event in a cevent list that matches the category target
0003 % If used without target, return the long duration among any categories
0004 % usage: cevent_longest_match(data, target)
0005 
0006   
0007 if (nargin == 2)
0008   index = find(data(:,3) == target);
0009 else
0010   index = [1:size(data,1)];
0011 end;
0012 
0013 if isempty(index)
0014   dur = 0;
0015 else
0016   length = data(index,2) - data(index,1);
0017   dur = max(length);
0018 end;
0019

Generated on Tue 23-May-2017 02:00:59 by m2html © 2005