How to create interrelated sliders?

18

4

Say I want a slider that controls the value of $x$ and another slider that controls the value of $2x$, how would I go about it?

Peteris

Posted 2012-02-05T21:54:57.797

Reputation: 283

1Is it purely abstract question or you need this for something else? I am curios what you're trying to achieve with this. – Vitaliy Kaurov – 2012-02-05T22:47:28.257

Need this for a tool that helps me to play around with speed (split time) / time / distance for the rowing machine. – Peteris – 2012-02-06T10:20:17.153

Answers

17

This?

{Slider[Dynamic[x], {0, 10}], 
 Slider[Dynamic[2 x, Set[x, #/2] &], {0, 20}]}

enter image description here

The documentation explains, under More Information, that "Dynamic[expr,f] makes interactive operations not change expr except by virtue of the evaluation of f[val,expr]. ". Otherwise, Mathematica attempts to assign a value to 2x.

acl

Posted 2012-02-05T21:54:57.797

Reputation: 19 146