- #1
- 908
- 572
In the following example...
... we have created variables p1 and p2 that are local to the Manipulate block, and we use them to set up two locators on the ListPlot. Now if we want to create a large number of locators, we could manually type in a large number of p1, p2, p3, p4 ... and so on. But is there a way to build these arrays of named variables programmatically?
The above is just one example, but there are other constructs in Mathematica where an input to a function must contain multiple named variables. It would be nice to automate the creation of large lists like that.
Code:
Manipulate[
ListPlot[{p1, p2}, PlotRange -> {{0, 3}, {0, 3}}, Joined -> True],
{{p1, {0.5, 0.5}}, Locator},
{{p2, {1, 0.7}}, Locator}
]
... we have created variables p1 and p2 that are local to the Manipulate block, and we use them to set up two locators on the ListPlot. Now if we want to create a large number of locators, we could manually type in a large number of p1, p2, p3, p4 ... and so on. But is there a way to build these arrays of named variables programmatically?
The above is just one example, but there are other constructs in Mathematica where an input to a function must contain multiple named variables. It would be nice to automate the creation of large lists like that.