Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

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


  • Prev by Date: Re: How to install Combinatorica
  • Next by Date: Re: message 50001?
  • Previous by thread: message 50001?
  • Next by thread: Re: message 50001?