help-octave
[Top][All Lists]
Advanced

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

Re: How to find the 3 highest peaks in an array? tia sal22


From: Rick T
Subject: Re: How to find the 3 highest peaks in an array? tia sal22
Date: Thu, 3 Mar 2011 08:03:54 -1000

Thanks I new it was something simple :-)


On Thu, Mar 3, 2011 at 4:58 AM, William Krekeler <address@hidden> wrote:

Rick,

 

You could use sortrows on a matrix of the indexes and their corresponding peak values, then find the peak values > 5 and take the first three, or less than three if there are no matching peaks.

 

You might also look at peakdetect, see http://www.billauer.co.il/peakdet.html

 

Bill Krekeler

 

From: address@hidden [mailto:address@hidden] On Behalf Of Rick T
Sent: Thursday, March 03, 2011 4:40 AM
To: address@hidden
Subject: How to find the 3 highest peaks in an array? tia sal22

 

How to find the 3 highest peaks in an array tia sal22

 

Greetings All

I have some example code that will find the min and max

peaks of an array.  How would I go about adjusting the

code to find the  3 highest peaks over the value 5?

 

 example code:

a = [1 2 2 3 2 1 1 5 1 17 17 17 15 20 1 4 5 2 5 7 4 7];

p = 1:length(a);

b = diff([inf a])~=0;

aa = a(b); pp = p(b);

maxima = pp(find(aa>[aa(2:end) inf] & aa>[inf aa(1:end-1)]))

a_valmax=a(maxima(:,:))

minima = pp(find(aa<[aa(2:end) -inf] & aa<[-inf aa(1:end-1)]))

a_valmin=a(minima(:,:))

 


tia sal22




--
--
|======================================================|
|http://www.onewithall.net/                           
|======================================================|
|"Knowledge may be the Key"
|"But wisdom unlocks the door"
|"Absolute Power demands absolutely nothing"

"The bourgeois today burns as heretics and hangs as criminals those to whom he erects monuments tomorrow" ('Steppenwolf')

|======================================================|

reply via email to

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