0

Why does this work

Manipulate[ListPlot[{a[1],a[2],a[3]}], {a[1], 0, 1}, {a[2], 0, 1}, {a[3], 0, 1}]

But this doesn't?

Manipulate[ListPlot[Array[a, 3]], {a[1], 0, 1}, {a[2], 0, 1}, {a[3], 0, 1}]

How do I rewrite this for $3 \rightarrow 100$ without typing it out?

Mr Puh
  • 1,017
  • 6
  • 12
  • related? https://mathematica.stackexchange.com/questions/10604/how-are-parameters-evaluated-for-a-plot-in-manipulate – Mr Puh Oct 01 '20 at 14:45
  • The reason is that Manipulate its variables. Therefore, the a[i]'s from Array are not the same variables as the a[i]'s from Manipulate. You may see this by replacing the first by the second e.g. by:Manipulate[vars = Array[a, 3]; ListPlot[Array[a, 3] /. Array[a, 3] -> {a[1], a[2], a[3]}], {a[1], 0, 1}, {a[2], 0, 1}, {a[3], 0, 1}] – Daniel Huber Oct 01 '20 at 16:11

1 Answers1

3

If I understand your question correctly, you need to inject objects into the Manipulate, e.g.:

With[
    {arr = Array[a,3], control = Sequence@@Thread[{Array[a,3],0,1}]},
    Manipulate[ListPlot[arr],control]
]

enter image description here

Carl Woll
  • 130,679
  • 6
  • 243
  • 355