Services & Resources / Wolfram Forums / MathGroup Archive
-----

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: [mg96822] Re: newbie: programmatic sequence of plots?
  • From: "m.g." <mg at michaelgamer.de>
  • Date: Wed, 25 Feb 2009 04:07:58 -0500 (EST)
  • References: <go0j4b$n0o$1@smc.vnet.net>

On 24 Feb., 11:45, Tom Roche <tlro... at gmail.com> wrote:
> How to get a programmatic sequence of plots?
>
> As advertised by the Subject:, I'm new to Mathematica (specifically
> 7.0.0 for Students for 32-bit Windows on XP Pro) so please excuse any
> lapses in terminology. I'd also appreciate pointers to specific docs
> rather than just an RTFM.
>
> Since I'm currently unable to model the logistic map y=a y (1-y) (see
> previous post) I'm trying to do a series of plots of it, to see how
> behavior changes over time. I can get a plot of a single instance with
>
> Clear[a,y,y0,nRecurr];
> a=3.5;
> y0=0.4;
> nRecurr=50;
> ListPlot[
>   RecurrenceTable[{y[n+1]==a y[n] (1-y[n]),y[0]==y0},
>     y,{n,1,nRecurr}],Joined->True
> ]
>
> I can get a sequence of tables of values with
>
> Clear[a, y, y0, nRecurr, yinit, yinc, yfinal];
> a = 3.5;
> nRecurr = 50;
> yinit = 0.1;
> yinc = 0.01;
> yfinal = 0.2;
> For[y0 = yinit, y0 <= yfinal, y0 += yinc, Print[y0, ":\n",
>   RecurrenceTable[{y[n + 1] == a y[n] (1 - y[n]), y[0] == y0}, =
y, {n,
> 1, nRecurr}]]]
>
> But when I try to plot those values with
>
> Clear[a, y, y0, nRecurr, yinit, yinc, yfinal];
> a = 3.5;
> nRecurr = 50;
> yinit = 0.1;
> yinc = 0.01;
> yfinal = 0.2;
> For[y0 = yinit, y0 <= yfinal, y0 += yinc,
>   ListPlot[
>     RecurrenceTable[
>       {y[n + 1] == a y[n] (1 - y[n]), y[0] == y0}, y, {n, 1=
, nRecurr}
>     ]
>     ,Joined->True]
> ]
>
> I get absolutely nothing: no plot, no error message, no nada.
> Similarly, when I try to plot the difference between two runs of the
> map with
>
> seqDiff[a_,y_,inc_]:=Module[
>   {r=y,s=y+inc},
>   ListPlot[
>     Table[r=a r (1-r),{50}]-Table[s=a s (1-s),{50}],
>     Joined->True,PlotRange->{-1,1}
>   ]
> ]
> seqDiff[4.0,0.3,0.1]
>
> I get a plot. But when I try to put that inside a for loop
>
> Clear[a, i,init,inc,final];
> a = 4.0;
> init=0.3;
> inc=0.1;
> final=0.5;
> For[i=init,i<=final,i+=inc,seqDiff[a,i,inc]]
>
> I get nothing: no plot, no error message.
>
> What am I doing wrong? How to get a series of plots?
>
> TIA, Tom Roche <Tom_Ro... at pobox.com>

Hello Tom,

 I think the reason for getting no graphics output ist, that your code
produces graphics-objects and these are not shown in this loop. To
show them you could do it like this: gatheriong the objects in a bag
and showing at the end o calculation (it=B4s a quick and dirty
modification of your code -  I know - this could be done much more
elgenatly, eg. with an own Module).

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 *)


Have you seen the excellent example of the logisitc map in the help
referring to the function RecurrenceTable (-> bifurcation of the
logistic map)?

Greetings

Mike


  • Prev by Date: Re: newbie: programmatic sequence of plots?
  • Next by Date: Re: newbie: how to define, typeset a multi-rule function?
  • Previous by thread: Re: newbie: programmatic sequence of plots?
  • Next by thread: Re: newbie: programmatic sequence of plots?