Every time you change n
, the inner Manipulate
expression gets re-evaluated, so of course all its variables, which in this case are all controls, get reinitialized. The way to fix it is to get rid of the nesting and have only one Manipulate
expression, You don't need the outer DynamicModule
either (a Manipulate
expression is transformed into a dynamic module when it is evaluated, so your code produces three nested levels of dynamic modules.)
So what you need is much simpler than what you wrote.
Manipulate[
Plot[(ε V)/(1 + Γ D), {D, 0, n}],
{{n, 5}, 1, 10, 1, Appearance -> "Labeled"},
{{V, 2}, 0, 5, Appearance -> "Labeled"},
{{Γ, .5}, 0, 1, Appearance -> "Labeled"},
{{ε, 1}, 0, 5, Appearance -> "Labeled"}]
Notes
- Instead of having
n
displayed in a panel, I use the option Appearance
to display its value on the right-hand side of its slider. I do the same for the other controls because I think it is almost always good make the current value of the controls visible.
- Presuming that
n
is meant to represent an integer variable, I have constrained its slider to step by 1.
- I have added explicit initialization to all the controls.
Manipulate[ Plot[(\[CurlyEpsilon] V)/(1 + \[CapitalGamma] D), {D, 0, n}], {V, 0, 5}, {\[CapitalGamma], 0, 1}, {\[CurlyEpsilon], 0, 5}, {n, 1, 10} ]
$\endgroup$