# How do I animate just one variable out of three inside Manipulate/Not show line until Animate?

1) In the following code, I want to Animate just the Elapsed Time (t) variable. How do I write an Animate inside the Manipulate?

2) How do I have the graph not show until the animation? I want the red line to advance along with the ball, not just have the ball follow the red line's already shown path.

f[t_, v_, a_] :=v*Cos[a Degree]*t        (*the x value at time t*)
g[t_, v_, a_] :=v*Sin[a Degree]*t - (9.82*t^2)/2 (*the y value at time t*)
c[t_, v_, a_] := {f[t, v, a],Max[g[t, v, a], 0]} (*the x and y value at time t*)
xmax[v_, a_] := (v^2*Sin[2*a])/9.8   (*x value when ball hits ground*)
ymax[v_, a_] := (v^2*(Sin^2)[a])/19.6   (*maximum height*)
tmax[v_, a_] := (v*Sin[a Degree]/4.9)  (*time when ball hits ground*)

Manipulate[
Show[
ParametricPlot[
{f[t, v, a], Max[g[t, v, a], 0]}, {t, 0, 20},
PlotStyle -> {Thick, Red}],          (*close parametric plot*)
ListPlot[
{c[t, v, a]},
PlotStyle -> {Black, PointSize[0.025]}
],          (*close list plot*)
PlotRange -> {{0, 250}, {0, 125}},
ImageSize -> Full,
AspectRatio -> Automatic,
AxesOrigin -> {0, 0},
AxesLabel -> {"x(t)", "y(t)"}
],          (*close show*)
{{t, 0.00001, "Elapsed Time (seconds)"}, 0.00001, 10, Appearance -> "Labeled"},
{{v, 50, "Initial velocity (m/s)"}, 1, 50, Appearance -> "Labeled"},
{{a, 45, "Initial angle (degrees)"}, 1, 90, Appearance -> "Labeled"},
Delimiter, SaveDefinitions -> True
]          (*close manipulate*)


• ParametricPlot[{f[tt, v, a], Max[g[tt, v, a], 0]}, {tt, 0, t}, PlotStyle -> {Thick, Red}] to get the end of the red line being at the position of the ball. – Karsten 7. Oct 5 '15 at 3:38
• @Karsten 7 That was perfect! I would like to set the variable t to "Open" instead of "Labeled" so the user can easily click on the play button. When I do that the countershows the end time 9.99999 instead of the initial time .00001. The result is as it was before your wonderful fix. How can I fix this? – Gwen Vastine Oct 5 '15 at 14:49
• That is a known bug. See for example mathematica.stackexchange.com/q/92860/18476 and the links therein. As I show in my answer a workaround for your situation is replacing the minimal value of t (0.00001) with 1/100000 or $MachineEpsilon. – Karsten 7. Oct 5 '15 at 16:19 • @Karsten 7 This was exactly what I needed. The$MachineEpsilon worked perfectly! – Gwen Vastine Oct 5 '15 at 21:07

You don't have to do anything. The control you are using to vary elapsed time is an Animator. All you have to do is open it by clicking on the + button on its right hand side. This exposes the animation controls and you are all set to go.

• Thank you @m_goldberg. What I would like the user to see is one button that says "Animate" without having to press the + button. The user would be able to vary the Initial Velocity and the Initial angle, but would not see any results until the "Animate" key was pressed. Until then the ball would remain at the origin. – Gwen Vastine Oct 5 '15 at 13:18
• I changed the variable t to "Open" instead of "Labeled" so that the user sees what you show above. How can I have the time show the initial time of .00001 instead of the end time 9.99999? – Gwen Vastine Oct 5 '15 at 14:51
f[t_, v_, a_] := v*Cos[a Degree]*t
g[t_, v_, a_] := v*Sin[a Degree]*t - (9.82*t^2)/2
c[t_, v_, a_] := {f[t, v, a], Max[g[t, v, a], 0]}

Manipulate[
Show[ParametricPlot[{f[tt, v, a], Max[g[tt, v, a], 0]}, {tt, 0, t},
PlotStyle -> {Thick, Red}],(*close parametric plot*)
ListPlot[{c[t, v, a]}, PlotStyle -> {Black, PointSize[0.025]}],(*close list plot*)
PlotRange -> {{0, 250}, {0, 125}}, ImageSize -> Full,
AspectRatio -> Automatic, AxesOrigin -> {0, 0},
AxesLabel -> {"x(t)", "y(t)"}],(*close show*)
{{t, 0.00001, "Elapsed Time (seconds)"}, \$MachineEpsilon, 10,
Appearance -> {"Open", "Labeled"}},
{{v, 50, "Initial velocity (m/s)"}, 1, 50, Appearance -> "Labeled"},
{{a, 45, "Initial angle (degrees)"}, 1, 90, Appearance -> "Labeled"},
Delimiter,SaveDefinitions -> True]