Re: Redundant manipulate
- To: mathgroup at smc.vnet.net
- Subject: [mg88869] Re: [mg88853] Redundant manipulate
- From: John Fultz <jfultz at wolfram.com>
- Date: Tue, 20 May 2008 02:23:34 -0400 (EDT)
- Reply-to: jfultz at wolfram.com
On Mon, 19 May 2008 05:17:33 -0400 (EDT), wiso wrote: > I have a manipulate like this: > > Manipulate[ > Row[{"a = ", a, " b = 2 a = ", b = 2 a}] > , {a, -10, 10, 1}, {b, -20, 20, 1}] > > If I change a, then b changes, but I also want that when I change b, > then a changes. Thanks. You could do this by using a custom control with a Dynamic that has a specialized setting function. Manipulate[ Row[{"a = ", a, " b = 2 a = ", b}], {{a, 0}, Slider[Dynamic[a, (b = 2 #; a = #) &], {0, 10, 1}] &}, {{b, 0}, Slider[Dynamic[b, (a = #/2; b = #) &], {0, 20, 2}] &}] See the documentation for Dynamic to see how the second argument works. One of the common uses of the second argument is to allow for variables which are linked in exactly this fashion. Note that I also fixed the step size of b to be 2, which makes it consistent with what I think you intended. Sincerely, John Fultz jfultz at wolfram.com User Interface Group Wolfram Research, Inc.