MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: message 50001?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg50037] Re: message 50001?
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Thu, 12 Aug 2004 05:44:02 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

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


  • Prev by Date: Re: Optional Alternatives
  • Next by Date: Re: message 50001?
  • Previous by thread: Re: message 50001?
  • Next by thread: Re: message 50001?