Message Boards Message Boards

Avoid control variable in Manipulate displaying unexpected values?


I have a Manipulate command in which the control variable runs over an interval which includes zero and with a specific increment. When the slider value is near zero, the value displayed can be an exact zero or an approximate zero depending upon how it was approached. Try the following and note that "sliding" onto zero is no problem, but incrementing to zero from either direction gives an inexact zero representation. This can be overcome with a Chop command, but I can't seem to change the actual display of the value that way. Here's a simplified command to try:


Is there any way to "manipulate" the control variable to avoid this behavior?

POSTED BY: William Vaughn
11 months ago


Sometimes Manipulate is limiting. Since Manipulate is build on Dynamic you can add your custom functionality by doing something like this:

Panel[Column[{Row[{Slider[Dynamic[x], {-.5, 2.0, 0.01}], Dynamic[x]}],
    ButtonBar[{"-" :> (x = Chop[x - .01]), 
     "+" :> (x = Chop[x + .01])}], Dynamic[N[x, 20]]}]]

Naturally, you can clean it up and make it nicer looking and add more functionality.


POSTED BY: Neil Singer
10 months ago

Group Abstract Group Abstract