Possible Duplicate:
How to create interrelated sliders?
locking a value when manipulating variables
I need to create a Manipulate
with two control parameters which are linked by some mathematical relationship. So the user can decide to use either control and when that control is changed, the other will change too.
The example below works as required, using If
statements to determine if one of the parameters has been changed and setting the other parameter appropriately.
Although this code works, I suspect there is a better/neater approach which avoids the need to "manually" keep track of oldx
and oldy
. What is the best way to do it?
oldx = oldy = 0;
Manipulate[
If[x != oldx, y = 1/x; oldx = x];
If[y != oldy, x = 1/y; oldy = y];
{x, y},
{x, 0.1, 10}, {y, 0.1, 10}]