help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: find array maximun in matrix


From: Nicholas Jankowski
Subject: Re: find array maximun in matrix
Date: Mon, 13 May 2019 14:08:00 -0400

On Mon, May 13, 2019 at 1:22 PM shivax via Help-octave <address@hidden> wrote:
hi, look that:

a=[4 6 1 6  7 9 1 2 3 4]


i want to find maximun series in matrix:

ans: [4 6 6 6 7 9 9 9 9 9]

i can to do this:

maxx=a(1);

for i=2:length(a)
   if a(i)>maxx(i-1)
     maxx(end+1)=a(i);
  endif
end

but I wanted to write a faster code avoiding the cycle


the function cummax  (cumulative or running maximum) will do this for you 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]