next up previous
Next: Check yourself by this Up: Waves Previous: Reading and writing external

Visualizing wave equation solutions in MATLAB

Now that we know something about waves and about about how to plot data using MATLAB, let us try to visualize a wave in MATLAB. We said a function of the form p=f(x - c t) where f is an arbitrary function represents a forward going wave.

If we look at the function tex2html_wrap_inline393 for a speed of c=1, we can plot it for times t=0 and t=5 as a function of x by using the following MATLAB statements:

 xlist = linspace(-10,10,200);

pbegin=exp(-(xlist - 1*0).^ 2);

pend=exp(-(xlist - 1*5).^ 2);

plot(xlist, pbegin, xlist, pend)



One can clearly see that the wave is a pulse which is moving forward in the x direction.

Tue Feb 25 21:24:33 EST 1997