Re: message 50001?
- To: mathgroup at smc.vnet.net
- Subject: [mg50028] Re: [mg50001] message 50001?
- From: DrBob <drbob at bigfoot.com>
- Date: Thu, 12 Aug 2004 05:43:42 -0400 (EDT)
- References: <200408110952.FAA04080@smc.vnet.net>
- Reply-to: drbob at bigfoot.com
- Sender: owner-wri-mathgroup at wolfram.com
Here are a couple of methods. The first allows multiple (tied) peaks. The second finds the first maximum. s=RandomArray[BinomialDistribution[17,.15], 20] Flatten@Position[s,Max@s,1] First@Flatten@Position[s,Max@s,1,1] {2,6,0,3,2,3,2,5,4,5,1,2,4,2,2,2,3,1,2,2} {2} 2 Bobby On Wed, 11 Aug 2004 05:52:54 -0400 (EDT), 1.156 <rob at pio-vere.com> wrote: > Mathematica wizards, I've managed to cripple together code to do something that > I feel must be doable more easily and/or faster. > > 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? > > Thanks, Rob > > > -- DrBob at bigfoot.com www.eclecticdreams.net
- References:
- message 50001?
- From: "1.156" <rob@pio-vere.com>
- message 50001?