This is because Manipulate
parameters are local.
mu
in Manipulate[ Plot[ g[x], {x, -10, 10}], {{mu, 1}, 0, 2 \[Pi]}]
is different from the global mu
that you clear in the previous line.
I suggest using
g[x_, mu_] := (x Sin[mu])^2 Manipulate[Plot[g[x, mu], {x, -10, 10}], {{mu, 1}, 0, 2 \[Pi]}]
The following works, but it continues to change the value of the global variable, which may cause surprises later if you do not pay attention, therefore I do not recommend:
g[x_] := (x Sin[mu])^2 Manipulate[ mu = mu2; Plot[g[x], {x, -10, 10}], {{mu2, 1}, 0, 2 \[Pi]} ]
It may happen that you are Clear[mu]
, but find that it gets the value when you scroll the Manipulate object in the view.
source share