MathGroup Archive 2013

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

Search the Archive

Re: updating a simulation within Manipulate.


FYI;

On V 9.0.1 on windows, when I run the code, (checked the `keepWalking` box, then
I get flood of these errors  on the console:

RandomVariate::realprm: Parameter bias at position 1 in NormalDistribution[bias,1] is expected to be real. >>


On 3/7/2013 9:48 PM, W Craig Carter wrote:

>
> 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: Re: Mathematica 9 install
  • Next by Date: Re: updating a simulation within Manipulate.
  • Previous by thread: Re: updating a simulation within Manipulate.
  • Next by thread: Re: Fixed Typo in Code---> Re: updating a simulation