annotate toolboxes/bioakustik_tools/math/maxsum.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function [startf,stopf,maxsofar]=maxsum(in)
Daniel@0 2
Daniel@0 3 maxsofar=0;
Daniel@0 4 maxendinghere=0;
Daniel@0 5 startf=1;
Daniel@0 6 stopf=1;
Daniel@0 7 aktstartf=1;
Daniel@0 8
Daniel@0 9 for i=1:length(in)
Daniel@0 10 if (maxendinghere+in(i) < 0)
Daniel@0 11 maxendinghere=0;
Daniel@0 12 aktstartf=i+1;
Daniel@0 13 else
Daniel@0 14 maxendinghere=maxendinghere+in(i);
Daniel@0 15 end
Daniel@0 16
Daniel@0 17 if(maxendinghere > maxsofar)
Daniel@0 18 maxsofar=maxendinghere;
Daniel@0 19 stopf=i;
Daniel@0 20 startf=aktstartf;
Daniel@0 21 end
Daniel@0 22 end