1
$\begingroup$

I have a paragraph

Manipulate[
    expr,
    { {a, 1}, 1, 4, 1},
    { {b, 2}, 2, 5, 1}
]

and I want variable b to be bigger than a at all times.

I have searched for help on this and one thread on this site mentions the functions Manipulate and Dynamic, but as I am new to Mathematica I don't fully understand the solution - and as I won't need Mathematica too much in the future it's not expedient for me to read through 5 page tutorials on both functions until I maybe get how both work.

Thanks in advance

$\endgroup$
  • $\begingroup$ Does this or linked topics answer your question?: Interdependent controls in Manipulate $\endgroup$ – Kuba Nov 26 '16 at 19:33
  • $\begingroup$ Manipulate[a + b, {{a, 1}, 1, 4, 1}, {b, a + 1, a + 6, 1}] $\endgroup$ – Alan Nov 26 '16 at 20:14
2
$\begingroup$

You can assign dependencies between the Manipulate variables. For example:

Manipulate[If[b < a, {a, b} = {Min[a, b], Max[a, b]}]; {a, b}, 
          {{a, 1}, 1, 4}, {{b, 2}, 2, 5}]
| improve this answer | |
$\endgroup$
0
$\begingroup$

Extending the comment by Alan with a TrackingFunction to ensure that also the value of b is increased whenever necessary:

Manipulate[a + b,
 {{a, 1}, 1, 4, 1, TrackingFunction -> (a = #; If[b <= a, b = a + 1]; &)},
 {b, a + 1, a + 6, 1}]
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.