% Plots left- and right-going waves, and resulting standing wave.
% Reflection at left of figure, at position zero.

gam = 0.9;  % reflection coefficient at origin
r  =  0.:.1:20; % positions for sampling of field 
t  =  0.;
clear M; % clear video frame storage
for j = 1:100
   t  =  t + .1;
   plot (r, cos(t + r), '-k'); % incoming wave from the left
   axis ([0 20 -2 2]);
   hold on
   plot (r, gam.*cos(t - r), '-k'); % reflected wave
   plot (r, gam.*cos(t - r) + cos(t + r), '.-b');
   title ('Standing Wave');
   xlabel ('Position');
   ylabel ('Voltage');
   hold off
   M(j) = getframe;
end
movie(M)
 
