Re: a question about plot a list of functions.

• To: mathgroup at smc.vnet.net
• Subject: [mg58211] Re: [mg58203] a question about plot a list of functions.
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Thu, 23 Jun 2005 05:33:47 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```Use Evaluate

K=(2 r/(1-r^2))^2;
y=1/(1+K (Sin[x])^2);
y=y/.{r->{0.2,0.9,0.995}};

Plot[Evaluate[y],{x,0,10 Pi}];

or

Needs["Graphics`"];

Clear[y];

y[x_,r_]:=Module[
{K=(2 r/(1-r^2))^2},
1/(1+K Sin[x]^2)];

Plot[Evaluate[
y[x,#]&/@{0.2,0.9,0.995}],
{x,0,10Pi},
ImageSize->400,
PlotStyle->(Hue/@{.6,.4,0}),
Ticks->{PiScale[0,10Pi,10],Automatic}];

Bob Hanlon

>
> From: Zhou Jiang <jiangzhou_yz at yahoo.com>
To: mathgroup at smc.vnet.net
> Date: 2005/06/22 Wed AM 01:55:51 EDT
> Subject: [mg58211] [mg58203] a question about plot a list of functions.
>
>
> I defined a function as
>
> K=(2 r/(1-r^2))^2;
> y=1/(1+K (Sin[x])^2);
> y=y/.{r->{0.2,0.9,0.995}}
>
> Now the result is a list.
> I want to plot y vs. x in one figure and I did the following
>
> Plot[y, {x, 0, 10 Pi}];
>
> But Mathematica gave me an error.
> I changed it to
>
> Plot[{y[[1]], y[[2]], y[[3]]}, {x, 0, 10 Pi}];
>
> Mathematica gave me a correct plot. Can anyone give me some idea why
the error message is given by Mathematica since y is a list and nothing is
diffrent from {y[[1]], y[[2]], y[[3]]}?
>
> Thanks.
>
>
>

```

• Prev by Date: Re: Mathematica program generating sequence of points stalls for no apparent reason.
• Next by Date: Re: a small problem from a newbee...
• Previous by thread: Re: a question about plot a list of functions.
• Next by thread: Re: a question about plot a list of functions.