Mercurial > hg > camir-aes2014
diff toolboxes/bioakustik_tools/math/maxsum.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toolboxes/bioakustik_tools/math/maxsum.m Tue Feb 10 15:05:51 2015 +0000 @@ -0,0 +1,22 @@ +function [startf,stopf,maxsofar]=maxsum(in) + +maxsofar=0; +maxendinghere=0; +startf=1; +stopf=1; +aktstartf=1; + +for i=1:length(in) + if (maxendinghere+in(i) < 0) + maxendinghere=0; + aktstartf=i+1; + else + maxendinghere=maxendinghere+in(i); + end + + if(maxendinghere > maxsofar) + maxsofar=maxendinghere; + stopf=i; + startf=aktstartf; + end +end \ No newline at end of file