I'm trying to setup a Manipulate where I have a variable number of sliders similar to this one, where every slider controls a function. In my case, there will be an additional slider which sets the number of functions.

I've tried with

    Manipulate @@ 
      {Plot[Table[Cos[2\[Pi]Subscript[h, i]x], {i, 1, n}], {x, 0, 1}], 
       Sequence@@Table[{Subscript[h, i], 0, 1}, {i, n}]}], 
  {{n, 1, "Waves"}, 1, 4, 1}]

but that does not work. I hope I have been successful in explaining my problem.

For instance this is partially working, except I can not add controls on functions, i.e. Subscript[h,i] in a nested manipulate

    trange = {t, 0, tmax},
    plotrange = {{0, xmax}, {-1, 1}},
    aspectratio = 1/xmax,
    f = Table[Cos[2 \[Pi] i t], {i, 1, n}]
    Plot[Evaluate[f], Evaluate[trange], PlotRange -> plotrange, 
    AspectRatio -> aspectratio]
  {tmax, 0.1, 1},
  {xmax, 0.1, 1},
  {n, 1, 4, 1}

1 Answer 1


In your construction, it will evaluate {Plot[...],..} first and then apply Manipulate. Plot[..] will become empty graphics since it didn't know about Subscript[h,1]. The following will be the better construction for this purpose:

 With[{controls = Sequence @@ Table[{Subscript[h, i], 0, 1}, {i, 1, n}], 
       func = Table[Cos[2 \[Pi] Subscript[h, i] x], {i, 1, n}]}, 
       Manipulate[Plot[func, {x, 0, 1}], controls, Paneled -> False]], 
 {n, 1, 10, 1}]
  • $\begingroup$ Great now it works perfectly. I am figuring what went wrong... Thank You very much! However, it does not save the values for the sliders, i.e. they clear every time I change n. $\endgroup$
    – Fabio
    Oct 31, 2013 at 9:11

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.