| Author |
Comment/Response |
Peter Pein
|
11/11/12 10:10am
Hi,
the infix operator for the logical and is "&&" [1]:
u[x_, t_] = Piecewise[{
{t, -1 < x - t < 1 && -1 < x + t < 1},
{1/2 (1 - x + t), -1 < x - t < 1 && x + t > 1},
{1/2 (x + t + 1), x - t < -1 && -1 < x + t < 1},
{1, x - t < -1 && x + t > 1}
(*,
* default value is 0
* {0, x + t < -1},
* {0, x - t > 1}
*)
}];
Manipulate[
Plot[u[x, t], {x, -10, 10}, PlotRange -> {0, 1.05 t}(*looks better IMHO*)],
{t, 0, 1, .01}
]
Peter
[1]: http://reference.wolfram.com/mathematica/ref/And.html
URL: , |
|