1

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

Karsten7
  • 27,448
  • 5
  • 73
  • 134
GoNiners
  • 11
  • 1

2 Answers2

2

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}]
bill s
  • 68,936
  • 4
  • 101
  • 191
0

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}]
Karsten7
  • 27,448
  • 5
  • 73
  • 134