Please have a look at the code below. The second Manipulate
uses the name rl
of the replacement rule given in the first line, but unlike the first Manipulte
, it does not plot anything, at least not on my computer. What goes wrong and how should I correct it? And why is %
immune to the problem?
rl = {ρ -> 1 / 5 Sqrt[25 - 25 z^2 + 10 Sin[5 ϕ] + Sin[5 ϕ]^2]};
Manipulate[PolarPlot[ρ /. % // Evaluate, {ϕ, 0, 2 Pi}], {z, -1, 1}]
Manipulate[PolarPlot[ρ /. rl // Evaluate, {ϕ, 0, 2 Pi}], {z, -1, 1}]
With[{rl = rl // Evaluate}, Manipulate[PolarPlot[\[Rho] /. rl, {\[Phi], 0, 2 Pi}], {z, -1, 1}]]
- read the documentation, understand the scoping behavior ofManipulate
... $\endgroup$ – ciao Apr 30 '16 at 9:43%
works. $\endgroup$ – QuantumDot Apr 30 '16 at 9:47Manipulate
is a scoping construct so the second example which is not working is behaving correctly :-)z
defined inrl
is different thanz
fromManipulate's
spec part, or will be as soon asManipulate
is evaluated. So at the end you should useWith
as ciao showed or define a function and passz
andϕ
. This of course doesn't explain why%
works. Maybe there are some special rules about how FrontEnd reads%
andOut[_]
, would be good to know. $\endgroup$ – Kuba♦ Apr 30 '16 at 10:06%
is expected to be replaced asap? $\endgroup$ – Kuba♦ Apr 30 '16 at 10:11