clear all
n=15;

d=0.1;
x = [-0:d:n];
y = [-7:d:n];
nn=60 
j=0;
M = moviein(nn);
for j=1:nn

  % Parameters for different media
  % free space: aa=0, bb=1, cc=0
  % plasma medium: aa=1, bb=0 cc=pi/2
  % very lossy medium: aa=1, bb=1, cc=pi/4
  aa=1;
  bb=1;
  cc=pi/4;
			  
  z =exp(-0.3*x*aa).*cos(bb*x-j*2*pi/nn);
  z2=exp(-0.3*x*aa).*cos(bb*x-j*2*pi/nn+cc);

  plot(x+round(100*z2)/30,z2,'r');
  hold on
  plot(x,z);
  plot(x,z2.*z,'g');

  legend('E-field','H-field','Power Density')

  plot(y,y*0,'k');
  plot(y,0.3*y,'k');
  plot(y,1e9*y,'k');

  hold off
  %grid
  axis([-4 10 -1.1 1.1])


  M(:,j) = getframe;
end

movie(M,100,10)

