MathGroup Archive 2013

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

Search the Archive

updating a simulation within Manipulate.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg130075] updating a simulation within Manipulate.
  • From: W Craig Carter <ccarter at MIT.EDU>
  • Date: Thu, 7 Mar 2013 22:51:42 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net


I *think* I've asked this question before, but I can't find it on mathgroup. In any case, I don't know the answer now.

Here is a simple example of a Manipulate that updates a graphic as long as a boolean is true.  This method seems like a kludge to me---is it? If so, what would be a better way to do this.

This is a constructed example, the real case I am looking at is much more involved; but kudos to anyone who can make a reasonable facsimile of their signature by adjusting the random walker's bias....

randomStep[bias_, stepList_] :=
 Module[{angle = RandomVariate[NormalDistribution[bias, 1]]},
  Join[stepList, {Last[stepList] + {Cos[angle], Sin[angle]}}]]

walkerGraphic[stepList_, range_] :=
 Graphics[GraphicsComplex[stepList, Disk /@ Range[Length[stepList]]],
  PlotRange -> range {{-1, 1}, {-1, 1}}]

DynamicModule[
 {walkerPath = {{0, 0}}},
 Manipulate[
  If[keepWalking,  (*  kludge warning---testing for If[True...] seems inefficient   *)
   walkerPath = randomStep[bias, walkerPath]
   ];
  If[reset,
   reset = False; keepWalking = False;
   walkerPath = {{0, 0}}
   ];
  walkerGraphic[walkerPath, range],
  {{keepWalking, False}, {True, False}},
  {{reset, False}, {True, False}},
  Delimiter,
  {{range, 20}, 0, 100},
  {{a, 0}, -Pi, Pi,
   AngularGauge[##, ImageSize -> 160 ,
     ScaleOrigin -> {{-4 Pi, 4 Pi}, 1}] &}
  ]
 ]



W Craig Carter
Professor of Materials Science, MIT


  • Prev by Date: dark halo around gaussian peak in Plot3D?
  • Next by Date: Re: dark halo around gaussian peak in Plot3D?
  • Previous by thread: Re: dark halo around gaussian peak in Plot3D?
  • Next by thread: Re: updating a simulation within Manipulate.