0
|
433 Views
|
4 Replies
|
5 Total Likes
View groups...
Share
Share this post:

# Using a symbol for the formula in Plot3D

Posted 1 month ago
 I have trouble using Plot3D when a symbol (ww2) is used. When I type the equation of the symbol, it works. Is there a fix or am I doing something wrong? Here is the code: ww2 = ww[x, y, t] /. ParameterValues Animate[Plot3D[ww2, {x, 0, 1}, {y, 0, 1}, PlotRange -> {-0.0002, 0.0002}], {t, 0, 0.6}, AnimationRunning -> False] Animate[Plot3D[ 0.00014428744591651202 Sin[ 19.869176531592203 t] Sin[\[Pi] x] Sin[\[Pi] y] - 0.00007672191944394383 Sin[31.41592653589794 t] Sin[ 2 \[Pi] x] Sin[\[Pi] y] - 0.00007672191944394383 Sin[31.41592653589794 t] Sin[\[Pi] x] Sin[ 2 \[Pi] y] + 0.00005099415342212902 Sin[39.738353063184405 t] Sin[ 2 \[Pi] x] Sin[2 \[Pi] y], {x, 0, 1}, {y, 0, 1}, PlotRange -> {-0.0002, 0.0002}], {t, 0, 0.6}, AnimationRunning -> False] 
4 Replies
Sort By:
Posted 1 month ago
 Using With[...] works also. Thank you.
Posted 1 month ago
 The t inside Animate[Plot3D[ww2, {x, 0, 1}, {y, 0, 1}], {t, 0, 0.6}] is "localized," which means it is different than the t that shows up when ww2 is evaluated. Animate[] will replace all literally-occurring instances of the symbol t with the localized variable; however, Plot3D[ww2, {x, 0, 1}, {y, 0, 1}] contains no t. Yes, as I implied, the value of ww2 contains a t, but ww2 unevaluated is just the symbol ww2: no t. So when Animate[] sets the value of the local t, it does not affect the value of ww2.Animate[] does this so that the value of t outside the animation is not changed. This is important because when Animate[] changes the value t inside the animation, the change triggers a Dynamic[]-related update that redraws the plot. If you change the value of (global) t outside the animation, it won't affect the animation because it's a different t; and likewise, the changes Animate[] makes do not affect any calculations while the animation is running.To get it to work you can use @Gianluca's With[] code. Or you could do this: ww2[t_] = ww[x, y, t] /. ParameterValues; Animate[Plot3D[ww2[t], {x, 0, 1}, {y, 0, 1}, PlotRange -> {-0.0002, 0.0002}], {t, 0, 0.6}, AnimationRunning -> False] Or this: Animate[Plot3D[ww[x, y, t] /. ParameterValues, {x, 0, 1}, {y, 0, 1}, PlotRange -> {-0.0002, 0.0002}], {t, 0, 0.6}, AnimationRunning -> False] There's also an option, LocalizeVariables -> False, you could use, but many avoid that for the reasons given in my second paragraph: It makes the animation interact (unpredictably) with any calculation that is using the variable t at the same time.
Posted 1 month ago
 Not sure why my previous reply did not go through... Using "ww2[t_] = ww[x, y, t]" works. Thank you!
Posted 1 month ago
 Try moving the definition of ww2 inside Animate: Animate[ Plot3D[ww2, {x, 0, 1}, {y, 0, 1}, PlotRange -> {-0.0002, 0.0002}], {t, 0, 0.6}, AnimationRunning -> False] or using With: With[{ww2 = ww[x, y, t] /. ParameterValues}, Animate[Plot3D[ww2, {x, 0, 1}, {y, 0, 1}, PlotRange -> {-0.0002, 0.0002}], {t, 0, 0.6}]] 
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments