1

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}
 ]

enter image description here
but this works:

Manipulate[
 Plot[
  {
   Piecewise[{{(Sin[x - Pi/2 - t] + 1)/2, t <= x <= t + 2 Pi}}, 0]
   },
  {x, 0, 20},
  PlotRange -> All
  ],
 {t, 0, 20}
 ]

enter image description here

user
  • 1,877
  • 10
  • 19

0 Answers0