[Date Index] [Thread Index] [Author Index]
Re: message 50001?
On 8/11/04 at 5:52 AM, rob at pio-vere.com (1.156) wrote: >S is a list of reals containing a signal with a prominent peak in >amplitude. I simply want to find the index of the peak (x, the >number of entries into the list where the peak occurs). Here's what >I did. >For[i = 1, S[[i]] ? max[S], i++, x = i]; >Can some suggest a better way, especially one not using a For loop? Yes, Last@Ordering@S or if you have an earlier version of Mathematica that doesn't have the function Ordering Position[S,Max@S][[1,1]] Note, these two will not yield the same answer when the maximum value is repeated in the list. The first method using Ordering will give the index of the last occurance of the maximum. The other method using Position will give the index of the first occurance of the maximum. -- To reply via email subtract one hundred and four