Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: updating a simulation within Manipulate.
Replies: 1   Last Post: Mar 8, 2013 6:22 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Nasser Abbasi

Posts: 5,686
Registered: 2/7/05
Re: updating a simulation within Manipulate.
Posted: Mar 8, 2013 6:22 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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
>









Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.