N=160;
XY=zeros(1,N);
wave1=zeros(1,N); wave1(1:N*3/4)=sin((N*3/4:-1:1)/N*5*pi);
wave2=zeros(1,N);
wave3=zeros(1,N);
for loop1=N*3/4+1:4*N
wave2=[wave2(2:N) wave1(N)];
wave1(2:N)=wave1(1:N-1);
wave1(1)=sin(loop1/N*5*pi);
E_Total=10*(wave2-wave1);
H_Total=10*(wave2+wave1);
% E&H
figure(1); quiver3(XY,XY,[1:N],XY,E_Total,XY,0,'.r'); axis vis3d; axis equal; axis([-20 20 -20 20 0 N ]);
figure(1); hold on; quiver3(XY,XY,[1:N],H_Total,XY,XY,0,'.b'); hold off
% H only
% figure(1); quiver3(XY,XY,[1:N],H_Total,XY,XY,0,'.b'); axis vis3d; axis equal; axis([-20 20 -20 20 0 N ]);
title('E: red, H: blue');
getframe;
end
评论0