Manipulate curves [duplicate]

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

a = Table[
E^(-(\[Pi]^2/
2) (delta^2 Q^4 + 2 q0^2 (Q^3 - defocus Q)^2)), {defocus, 1, 4,
1}];
Manipulate[
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.

marked as duplicate by MarcoB, user9660, m_goldberg, Sjoerd C. de Vries, Yves KlettFeb 16 '16 at 6:08

• 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*)],...]. – MarcoB Feb 15 '16 at 17:54
• See also the docs of Manipulate, in the "Possible Issues" section: "Manipulate only "notices" explicit visible parameters". – MarcoB Feb 15 '16 at 17:57

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

Clear[a]

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

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