Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #13752
| From | W Craig Carter <ccarter@MIT.EDU> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Fixed Typo in Code---> Re: updating a simulation within Manipulate. |
| Date | 2013-03-08 03:47 +0000 |
| Message-ID | <khbn00$cd5$1@smc.vnet.net> (permalink) |
| References | <9C229A0A-D12F-4D3E-9B5F-7FA8B918CFE6@mit.edu> |
| Organization | Time-Warner Telecom |
On previous message, there is a typo in the example code, please use this instead:
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},
{{bias, 0}, -Pi, Pi,
AngularGauge[##, ImageSize -> 160,
ScaleOrigin -> {{-4 Pi, 4 Pi}, 1}] &}]]
W Craig Carter
Professor of Materials Science, MIT
On Mar 7, 13, at 17:16 PM, W Craig Carter wrote:
> 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
>
>
Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread
Fixed Typo in Code---> Re: updating a simulation within Manipulate. W Craig Carter <ccarter@MIT.EDU> - 2013-03-08 03:47 +0000 Re: Fixed Typo in Code---> Re: updating a simulation within Manipulate. "Nasser M. Abbasi" <nma@12000.org> - 2013-03-09 10:25 +0000
csiph-web