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