Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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}
share|improve this question

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}]
share|improve this answer
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. – Fabio Oct 31 '13 at 9:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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