comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function [startf,stopf,maxsofar]=maxsum(in)
2
3 maxsofar=0;
4 maxendinghere=0;
5 startf=1;
6 stopf=1;
7 aktstartf=1;
8
9 for i=1:length(in)
10 if (maxendinghere+in(i) < 0)
11 maxendinghere=0;
12 aktstartf=i+1;
13 else
14 maxendinghere=maxendinghere+in(i);
15 end
16
17 if(maxendinghere > maxsofar)
18 maxsofar=maxendinghere;
19 stopf=i;
20 startf=aktstartf;
21 end
22 end