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: [mg96811] Re: newbie: programmatic sequence of plots?
  • From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
  • Date: Wed, 25 Feb 2009 04:05:57 -0500 (EST)
  • References: <go0j4b$n0o$1@smc.vnet.net>

The problem is to get some visible effect from the execution of the
body of the For loop. Try replacing the whole ListPlot function with
just the variable y0. Would that give you a set of printed y0 values?
No, unless you use Print. Well, Print works for ListPlots as well.

Loops themselves only have a null return value.

In versions before 6, the showing of a plot after a Plot function was
a side effect, like a hidden Print function and it couldn't be
suppressed with a semicolon. The main effect was the generation of a
graphics structure (for use in assignments and Show and so). In 6 and
7 this behaviour has been changed and the generation of a directly
displayable Graphics structure is now the main (and only) effect. It
can be supressed by a semicolon and when generated in a loop it has to
be explicitely printed if visibility is desired.


Cheers -- Sjoerd

On Feb 24, 12:45 pm, 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>



  • Prev by Date: Re: newbie: programmatic sequence of plots?
  • Next by Date: Re: newbie: programmatic sequence of plots?
  • Previous by thread: Re: newbie: programmatic sequence of plots?
  • Next by thread: Re: newbie: programmatic sequence of plots?