Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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 am studying Dynamic and DynamicModule, and I have tried to make a simple plot of a family of real functions. The number of functions should be a dynamic variable controlled by a slider. So I have tried something like this

{Slider[Dynamic[z], {1, 4, 1}], Plot[Evaluate[Dynamic[Table[Sin[i*t], {i, 1, z}]]], {t, 0, 2 Pi}]}

In this case variable t is highlighted in red and the output is empty. But if you do it outside of Plot[], then you get a correct list of functions

{Slider[Dynamic[z], {1, 4, 1}], Evaluate[Dynamic[Table[Sin[i*t], {i, 1, z}]]]}

So, how one plots this kind of things?

share|improve this question
up vote 4 down vote accepted

The Plot has to be within Dynamic, as the Plot needs to be updated when z is changed. You can't just update the content of Plot without making a new Plot.

{Slider[Dynamic[z], {1, 4, 1}], 
 Dynamic@Plot[Evaluate[Table[Sin[i*t], {i, 1, z}]], {t, 0, 2 Pi}]}

The syntax highlighting is due to the Head of your command inside Plot being Dynamic

Evaluate[Dynamic[Table[Sin[i*t], {i, 1, z}]]] // Head
share|improve this answer
right, thank you) – Ivan Aug 16 '14 at 12:01

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.