Re: Dynamic changing of variables

*To*: mathgroup at smc.vnet.net*Subject*: [mg96370] Re: Dynamic changing of variables*From*: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>*Date*: Thu, 12 Feb 2009 06:38:52 -0500 (EST)*References*: <gmu8rl$gn3$1@smc.vnet.net>

The problem of updating a lies with its invisible dependence on b. If you make it explicitely dependent on b you can drop the first dynamic and a is not wrapped and can be used for calculations. DynamicModule[{a, b = 0}, a[b_] = Sin[b]; Column[{Dynamic[a[b]], Slider[Dynamic[b], {0, 2*Pi}]}]] Alternatively, you could have wrapped the whole assignment with Dynamic: DynamicModule[{a, b = 0}, Column[{Dynamic[a = Sin[b]], Dynamic[a + 1], Slider[Dynamic[b], {0, 2*Pi}]}]] Cheers -- Sjoerd On Feb 11, 12:21 pm, Patrick Scheibe <psche... at trm.uni-leipzig.de> wrote: > Hi, > > assume the following code lines: > > DynamicModule[{a, b = 0}, > a = Dynamic[Sin[b]]; > Column[{ > Dynamic[a], > Slider[Dynamic[b], {0, 2*Pi}] > }] > ] > > In order to update "a" with the actual value of Sin[b] I need > Dynamic around it. Unfortunately, now the variable "a" is invisibly > wrapped and completely useless for further calculations. I'm not able to > calculate even a+1 inside the DynamicModule. > > DynamicModule[{a, b = 0}, > a = Dynamic[Sin[b]]; > Column[{ > Dynamic[a+1], > Slider[Dynamic[b], {0, 2*Pi}] > }] > ] > > If I'm not just too stupid and this behaviour is intended, then I'm > wondering whether this doesn't lead to problems when you have more > complex constructs with several dynamic variables. > > Cheers > Patrick > > PS: I was just pointed by another person on this and I found a way > around it. So cannot provide a real problem I'm having. Nevertheless, I > would be glad to know what you think since I couldn't really find the > point in the documentation where this is explained.