MathGroup Archive 2009

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

Search the Archive

Re: newbie: programmatic sequence of plots?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg96921] Re: newbie: programmatic sequence of plots?
  • From: Tom Roche <tlroche at gmail.com>
  • Date: Fri, 27 Feb 2009 06:13:36 -0500 (EST)
  • References: <go0j4b$n0o$1@smc.vnet.net> <go31og$fga$1@smc.vnet.net>

Sjoerd C. de Vries Wed, 25 Feb 2009 09:05:27 +0000 (UTC)
> Loops themselves only have a null return value.

Doh! I was assuming ListPlot would have a "side effect."

Albert Retey Wed, 25 Feb 2009 09:06:32 +0000 (UTC)
> return a list of these plots additionaly or instead of just
> printing them, so that you can use ListAnimation or TabView or
> whatever you like for displaying them.

And the way to do that is

"m.g." Wed, 25 Feb 2009 09:07:28 +0000 (UTC)
> Clear[a, y, y0, nRecurr, yinit, yinc, yfinal];
> a = 3.5;
> nRecurr = 50;
> yinit = 0.1;
> yinc = 0.01;
> yfinal = 0.2;
> out = {};             (*  modification here *)
> For[y0 = yinit, y0 <= yfinal, y0 += yinc,
>   AppendTo[out,       (*  modification here *)
>     ListPlot[
>      RecurrenceTable[{y[n + 1] == a y[n] (1 - y[n]), y[0] == y0},
>       y, {n, 1, nRecurr}]]];
>   ];
> out                   (*  modification here *)

So I modified that to do

For[y0 = yinit, y0 <= yfinal, y0 += yinc,
  AppendTo[out,
    ListPlot[
      RecurrenceTable[{y[n + 1] == a y[n] (1 - y[n]), y[0] == y0},
        y, {n, 1, nRecurr}], Joined -> True
    ]
  ];
];
ListAnimate[out]

which is even better than printing a list of static plots.

Thanks all, Tom Roche <Tom_Roche at pobox.com>


  • Prev by Date: Re: newbie: diff equation
  • Next by Date: Re: Need some help with monitoring evaluation
  • Previous by thread: Re: newbie: programmatic sequence of plots?
  • Next by thread: Re: newbie: programmatic sequence of plots?