MathGroup Archive 2002

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

Search the Archive

Re: Plot several graphs generated by Table

  • To: mathgroup at smc.vnet.net
  • Subject: [mg36438] Re: Plot several graphs generated by Table
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Sat, 7 Sep 2002 02:53:45 -0400 (EDT)
  • Organization: Universitaet Leipzig
  • References: <al9lbf$b2b$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

could you supply a complete example next time ?
Try myfunc[] with a more restrictive pattern and 
it works:

myArray = Flatten[Table[{n, 1, Random[]}, {15}, {n, 1, 21}], 1];

myfunc[n_, pthreshold_?NumericQ] := 
  Module[{t}, 
    t = Max[Cases[myArray, {n, k_, p_} /; (p >= pthreshold) -> p, 2]];
    If[t >= 0, t, -1]]

Plot[Evaluate[Table[myfunc[n, p], {n, 1, 21}]], {p, 0.0, 1.0}]

Regards
  Jens




muh nochwaaa wrote:
> 
> myArray is a list of triplets which look like {n,k,p}, where n and k
> are integers  and p is real number. repetitions in n and k are allowed
> but no two triplets ar the same.
> 
> I define a function, myfunc[n_,pthreshold_] as follows.
> 
> myfunc[n_,pthreshold_] := Module[{t},
> t=Max[Cases[myArray, {n, k_, p_} /; (p >= pthreshold) -> p, 2]];
> If[t>=0,t,-1]]
> 
> It prints the largest k for which p is greater than pthreshold for a
> given n and
> -1 if there is no such k.  The function does its job fine.
> 
> My problem is as follows. I would like to plot a collection of plots,
> myfunc[n,p], for 1<=n<=21 with respect to p. unfortunately the
> following does not work as desired.
> 
> Plot[Table[myfunc[n,p],{n,1,21}],{p,0.0,1.0}]
> 
> because the Table gets evaluated to numeric value (-1) before Plot is
> invoked.
> How could I accomplish this? Thanks in advance for all your helps.


  • Prev by Date: RE: Fill the space surrounded by two contours lines with different colors
  • Next by Date: RE: Generating Two Unit Orthogonal Vectors
  • Previous by thread: Re: Plot several graphs generated by Table
  • Next by thread: RE: Plot several graphs generated by Table