MathGroup Archive 2000

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

Search the Archive

Re: Getting peak value from a Graph in Plot command - pls help

  • To: mathgroup at smc.vnet.net
  • Subject: [mg23987] Re: Getting peak value from a Graph in Plot command - pls help
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Mon, 19 Jun 2000 01:45:29 -0400 (EDT)
  • References: <8ihsiq$l5h@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Fannon,
Here for starters - you may want to add refinements to deal with plateaux ,
multiple max peaks, no peaks etc.

highestPeak[gr_] :=
  Reverse[
    Last[Sort[ReplaceList[Join @@ Cases[gr, Line[pts_] :> pts, Infinity],
          {___, {x1_, y1_}, {x2_, y2_}, {x3_, y3_}, ___} /;
              y1 < y2 && y2 > y3 -> {y2, x2}]]]]

Example:

gr = Plot[ Sin[x]/(1 + x), {x, 0, 12}];

highestPeak[gr]

--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

"Fannon Lim" <fannews at email.com> wrote in message
news:8ihsiq$l5h at smc.vnet.net...
> I would be grateful if anyone knows if there is any command that I can
> use to extract the highest peak value from a graph in a Plot command?
>
> Thanks alot!
>
> Cheers......
> Fannon
>
>
>




  • Prev by Date: Re: converting 2.2.3 (ma-notebooks) to 3.0 or 4.0 (nb)
  • Next by Date: Re: I wish Descending Order Result
  • Previous by thread: Re: Getting peak value from a Graph in Plot command - pls help
  • Next by thread: Re: Getting peak value from a Graph in Plot command - pls help