I want to draw curves with manipulation. When I use the following code, I receive nothing.

a = Table[
     2) (delta^2 Q^4 + 2 q0^2 (Q^3 - defocus Q)^2)), {defocus, 1, 4, 
 Plot[Evaluate[a], {Q, 0, 3}], {{q0, .05}, {.05, .1}}, {{delta, 
   0.1}, {0.1, 0.2}}]

But if I write explicitly the variable "a", I do receive what I need.

I've check the attributes of Manipulate, which has HoldAll. I don't know if it's related to this.

Could you please explain to me why it's like this ? Thanks a lot in advance.

  • $\begingroup$ Manipulate needs to "see" the parameters in the definition of a explicitly in order to be able to change them; move the definition of a inside the Manipulate: Manipulate[a=(*your code*); Plot[(*your code*)],...]. $\endgroup$ – MarcoB Feb 15 '16 at 17:54
  • $\begingroup$ See also the docs of Manipulate, in the "Possible Issues" section: "Manipulate only "notices" explicit visible parameters". $\endgroup$ – MarcoB Feb 15 '16 at 17:57

It is a scoping issue. Make the arguments to a explicit.


a[Q_, q0_, delta_] =
   E^(-(π^2/2) (delta^2 Q^4 + 2 q0^2 (Q^3 - defocus Q)^2)),
   {defocus, 1, 4, 1}];

  Evaluate[a[Q, q0, delta]],
  {Q, 0, 3},
  PlotLegends -> Automatic],
 {{q0, .05}, {.05, .1}},
 {{delta, .1}, {.1, .2}}]

enter image description here

| improve this answer | |

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