help-octave
[Top][All Lists]
Advanced

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

Re: Finding peaks/max in a graph


From: edA-qa mort-ora-y
Subject: Re: Finding peaks/max in a graph
Date: Mon, 05 Apr 2004 17:22:46 +0200
User-agent: Mozilla Thunderbird 0.5 (X11/20040208)

David Bateman wrote:
A for-loop is not the way to go about this. Consider the code fragment
n = 9
a = [1 2 3 4 5 4 3 2 1]';
peaks = find([a(2:n,1) - a(1:n-1,1) < 0; 1] & [1; a(1:n-1,1) - a(2:n,1) < 0]);
that will find all indexes of the peaks in the data in a single statement

If you set
  a = [1 2 3 4 5 4 3 2 1 2 3 2 1]';
Peaks will only find 5, not the 3 as well. I will see if somehow, however, I can modify my code not to use a for-loop, rather to use a similar notation to above.

--
edA-qa mort-ora-y
Idea Architect
http://disemia.com/



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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