More about getting variables out of Manipulate:

If I execute the following:

Manipulate[{xb1, xb2, xb3}, 
  {xb1, 0, 1}, 
  {xb2, 0, 1}, 
  {xb3, 0, 1}, 
  LocalizeVariables -> False]

I get 3 sliders and the list {0,0,0}. If I ask for the value of xb1, I get 0.

If I execute the similar form:

Manipulate[{xb[1], xb[2], xb[3]}, 
  {xb[1], 0, 1}, 
  {xb[2], 0,  1}, 
  {xb[3], 0, 1}, 
  LocalizeVariables -> False]

I get $3$ sliders and the list {0,0,0}. HOWEVER, if I ask for the value of xb[1], I just get xb[1]. Why? LocalizeVariables->False seems not to work in this case.

More importantly, how can I get a list of the values of the Manipulate variables as Global variables?

The actual case I'm using has multiple lists of Locator variables, which seems to be even more difficult to get at than, say, multiple lists of Slider variables.

            name_String, indexnumber_] := 
    pts = {{0, 0}, {inputrangex[[2]]/4, 0}, {inputrangex[[2]]/2, 0}, 
           {3 inputrangex[[2]]/4, 0}, {inputrangex[[2]], 0}}, 
    locatoricon = 
      Graphics[{Red, PointSize[Medium], Point[{0, 0}]}, ImageSize -> 18];
          InterpolatingPolynomial[pts, x], {x, 0, inputrangex[[2]]}, 
            PlotRange -> {inputrangex, inputrangey}, Frame -> True, 
            ImageSize -> Medium, Axes -> True, FrameLabel -> name]], 
        Appearance -> locatoricon, LocatorAutoCreate -> True],
      Button["Save", With[{p = pts}, points = p]]}]]

I would like to have used the argument indexnumber to be an index for each use of manipulate variables (one for each graph), but that doesn't work, probably because for the same reason the example using indexed variables in Manipulate given above doesn't work.

  • $\begingroup$ Maybe because xb[1] is not a Symbol and LocalizeVariables->False does not affect it. Just a guess... $\endgroup$
    – Kuba
    Nov 29, 2013 at 19:09
  • $\begingroup$ @Kuba is correct. You need to be using symbols. This would also fail for the same reason if you tried TrackSymbols for some dynamic operation $\endgroup$ Nov 29, 2013 at 23:07

1 Answer 1


The simplest way to capture a list of values in a global variable is to assign that variable directly, e.g.:

  xb = {xb1, xb2, xb3}
, {xb1, 0, 1}
, {xb2, 0, 1}
, {xb3, 0, 1}

In this example, xb1, xb2 and xb3 are kept localized to the Manipulate, but xb is global.

mathematica session screenshot


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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