Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'plotting a wave equation' topicStudent Support Forum > General > "plotting a wave equation"

< Previous CommentHelp | Reply To Comment | Reply To Topic
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: ,

Subject (listing for 'plotting a wave equation')
Author Date Posted
plotting a wave equation dustin 11/10/12 12:27pm
Re: plotting a wave equation yehuda 11/11/12 02:31am
Re: plotting a wave equation Peter Pein 11/11/12 10:10am
< Previous CommentHelp | Reply To Comment | Reply To Topic