A central feature of the Wolfram Demonstrations is the use of multiple instances of the Manipulate output, placed into the Thumbnail and Snapshots sections – for instance here, that are used to illustrate different control settings and corresponding displays. However that seems to preclude the use of Dynamic’s second argument for various control variables to either change the expression displayed, or to limit or constrain the choices available for other controls. To illustrate, the following shows the bare bones code for a Manipulate and two separate instances of its output with 3 three controls adjusted to give different displays:
Manipulate[
Plot[{Cos[frq$a x], Sin[frq$b x + plt$ph]}, {x, 0, 10},
ImageSize -> {250, 170}],
Row[{Style[Text["Multiplier 1: "], 12],
Slider[Dynamic[frq$a], {1, 10}]}],
Control[{{frq$b, 2, "Multiplier 2"}, 1, 4}],
DynamicModule[{ctrl, b},
Row[{Style[Text["Phase: "], 12],
Slider[Dynamic[
b, (b = #; ext$var$1 = b + 3; plt$ph = b + 3) &], {0, 10}]}]],
LocalizeVariables -> True,
Initialization :> (plt$ph = 3; frq$a = 5)]
In the display, changing either of the Multiplier 1 controls causes the physical position of the other one to change in lock-step, with both displays changing likewise. But changing either of the Multiplier 2 controls changes only that physical control setting (frq_b) along with the corresponding frequency (the red trace, the higher frequency sine wave in the right-most display). And, finally, in an attempt to get the unlinked features of the Multiplier 2 controls while keeping the necessary features of Dynamic associated with the Multiplier 1 control, I created a DynamicModule that incorporates another Slider control (plt_ph). However, while those two controls themselves are not physically linked – as indicated by their two different positions – when either one is changed the variable plt_ph is changed in both and both displays update accordingly.
So my question, though a bit of a wan hope, is whether there’s some way of obtaining that combination of features, i.e., the non-linked capability along with the ability to use Dynamic’s second argument to implement various other functions. Somewhat in passing, it seems suprising that the control Multiplier 2 – implemented as Control[{{frq_b, 2, "Multiplier 2"}, 1,4}] – creates a variable that seems to have separate instances, and values, between the two outputs. Consequently, it seems possible that something similar could implemented with the other control variable, plt_ph.
Manipulate
but evaluating your code I notice that the variables are not actually being localised. If you examine the underlying show expression you'll see that the two variables that are initialised do not make it into the list of local dynamic module variables. As a nonManipulate
user I do not intend to try and figure why the LocalVariables option doesn;t appear to be doing what you expect. Have you considered just usingDynamicModule
and avoid theManipulate
headaches? $\endgroup${{frq$a, 5, "Multiplier1"}, 1, 10}, Control[{{frq$b, 2, "Multiplier 2"}, 1, 4}], {{plt$ph, 3, "Phase"}, 1, 10}]
is enough? $\endgroup$Dynamic
: demonstrations.wolfram.com/TheGeometryOfLagrangeMultipliers $\endgroup$Manipulate
s. (I don't think that's allowed on the Demonstrations site. The "Snapshots" on the website are just rasterized images, not functioning copies of the demonstration.) $\endgroup$