The only difference is that in the second snippet the expression is written out explicitly.
displacement = (Sin[x - Pi/2 - t] + 1)/2
This doesn't work:
Manipulate[
Plot[
{
Piecewise[{{displacement, t <= x <= t + 2 Pi}}, 0]
},
{x, 0, 20},
PlotRange -> All
],
{t, 0, 20}
]
Manipulate[
Plot[
{
Piecewise[{{(Sin[x - Pi/2 - t] + 1)/2, t <= x <= t + 2 Pi}}, 0]
},
{x, 0, 20},
PlotRange -> All
],
{t, 0, 20}
]


Evaluated -> Trueto thePlot[]and try again. – J. M.'s missing motivation Oct 24 '15 at 10:38Manipulate[Table[displacement, {x, 0, 2}], {t, 0, 20}]. – J. M.'s missing motivation Oct 24 '15 at 10:51Table[]. That is what's happening toPlot[]too, which of course cannot plot anything with a dangling symbol. – J. M.'s missing motivation Oct 24 '15 at 17:07Manipulate[ Plot[ { Piecewise[{{(displacement /. t -> time), time <= x <= time + 2 Pi}}, 0] }, {x, 0, 20}, PlotRange -> All, Evaluated -> True ], {time, 0, 20} ]Have I understood correctly that the Manipulate function replaces all occurrences of t before evaluating the Piecewise. So because it doesn't contain t before evaluation it is left dangling. – user Oct 24 '15 at 17:25