Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Caution! Reuse of variables within Manipulate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg89053] Caution! Reuse of variables within Manipulate
  • From: Frank Iannarilli <frankeye at cox.net>
  • Date: Sat, 24 May 2008 03:57:21 -0400 (EDT)

Hi,


Here's a cautionary note about (re)use of dynamic variables inside
Manipulate[].

To wit, here's code to demonstrate the issue.  Note the reuse of the
variable d, and Pause[]:

Manipulate[
d = b;
Pause[1.];
d = Max[Sin[b], Sin[a]];
Plot[a Sin[b t], {t, 0, 10}, PlotRange -> {All, {-10, 10}}],
{{a, 1, "a"}, 0, 10, Appearance -> "Labeled"},
{{b, 1, "b"}, 0, 10, Appearance -> "Labeled"},
Item[Row[{Style["Goofy: ", Blue], Dynamic[d]}, Spacer[2]],
  Alignment -> Left]
]

As one plays with the controls, the display of Dynamic[d] (labeled by
"Goofy") will flicker, showing that indeed the variable d is dynamic
*every point through* the body of Manipulate.  I had naively assumed
that one's code within Manipulate would run through from top to bottom
before the display would be updated.

Is this surprising, or has this been mentioned in the Documentation?

Regards,
Frank


  • Prev by Date: Re: Re: Color space conversion in Mathematica v6.0
  • Next by Date: Re: LeastSquares using LinearProgramming?
  • Previous by thread: Re: Numbering weeks for the years of this century. An easy problem?
  • Next by thread: Re: Caution! Reuse of variables within Manipulate