Home > chronux > fly_track > FAnalyze > functions > FindDuration.m

FindDuration

PURPOSE ^

FINDDURATION

SYNOPSIS ^

function out = FindDuration(indx);

DESCRIPTION ^

FINDDURATION
   Usage: out = FindDuration(indx)

 This is a short little function that finds a jump in the indx vector
 and then spits out the number of elements before that jump.  It does
 this for all jumps it finds.  By a jump, I mean a discontinutity in the
 index.  For example, if the index vector is [1 2 3 4 5 8 9 10], there is
 a jump between 5 and 8.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function out = FindDuration(indx);
0002 
0003 %FINDDURATION
0004 %   Usage: out = FindDuration(indx)
0005 %
0006 % This is a short little function that finds a jump in the indx vector
0007 % and then spits out the number of elements before that jump.  It does
0008 % this for all jumps it finds.  By a jump, I mean a discontinutity in the
0009 % index.  For example, if the index vector is [1 2 3 4 5 8 9 10], there is
0010 % a jump between 5 and 8.
0011 
0012 %Written by Dan Valente
0013 %October 2007
0014 
0015 if isempty(indx)
0016     out = [];
0017     return;
0018 end
0019 
0020 m = 1;
0021 list = [];
0022 indx(end+1)=-1;  %Makes sure last section of indx (past final juump) is properly considered.
0023 for i = 1:length(indx)-1;
0024     if indx(i)+1 == indx(i+1)
0025         list = [list i];
0026     else
0027         list = [list i];
0028         out(m) = length(list);
0029         list = [];
0030         m = m+1;
0031     end
0032 end
0033 
0034 
0035 
0036 
0037         
0038

Generated on Fri 28-Sep-2012 12:34:30 by m2html © 2005