MathGroup Archive 1995

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

Search the Archive

news article for your approval

  • To: mathgroup at smc.vnet.net
  • Subject: [mg2844] news article for your approval
  • From: EmiNet Domain News Admin <news at emi.net>
  • Date: Sat, 23 Dec 1995 03:20:41 -0500

>From: drc at emi.net (David Cabana)
>To: mathgroup at smc.vnet.net
>Subject: what's wrong w this animation?
>Organization: EmiNet Domain Internet Services (407)731-0222

I am reading Gaylord and Wellin's "Computer Simulations with Mathematica".
I am having trouble with some of the code on the accompanying cd.  They
define a two-dimensional random walk as follows:

Walk2D[n_] := 
Module[{moves, randomChoices},
   directions = {{0,1}, {1,0}, {0,-1}, {-1,0}};
   randomChoices = Table[Random[Integer, {1, 4}], {n}];
   FoldList[Plus, {0,0}, directions[[randomChoices]] ] 
] 

Actually, I modified their definition by introducing a couple of local
variables to enhance readability.  That code works well; the trouble
starts when I try to use their code for animating the walk.

AnimateWalk2D[coords_, opts___]:=
   Map[Show[Graphics[{
      {RGBColor[1,0,0],PointSize[.1],
       Point[ coords[[#]] ]},
      Line[Take[coords, #]]}],
    opts,
    AspectRatio -> Automatic,
    PlotRange -> Map[{Min[#]-.2, Max[#]+.2}&,
                   Transpose[coords]]]&, 
                   Range[2, Length[coords]]]
       
When I run 
   AnimateWalk2D[ Walk2D[10] ] 
I get 10 separate images rather than an animation.  What's wrong?

-- 
David Cabana    drc at gate.net 

"To stand in silence when they should be protesting makes cowards of men." 
          Abraham Lincoln


  • Prev by Date: trouble installing mathematica
  • Next by Date: Re: Mathlink & Macintosh & CodeWarrior
  • Previous by thread: trouble installing mathematica
  • Next by thread: implicit differentiation