%EM Linear and circular wave propagation.. %Kenyon fig. 10.1 p.278 %Circular E wave propagating along the X axis. %E field is along the yz plane (E1_0 z^ + E2_0 y^) % Direction of propagation s^ = -z^ X y^ = x^ % Steven Sahyun November 10, 2014 clf(); clear; t=0; %max=2; %for size of graph %x = 0; w = 1/10; while(1) %wavelength = input('Wavelength (nm) = '); lambda = 500; % Set at 500 nm, uncomment above if you want to choose the wavelength in the program. Ez_0 = 100; % Electric field amplitude Ez_0 = input('Input Ez_0 Amplitude (0-100) = '); Ey_0 = 100; % E field initially equal component Ey_0 = input('Input Ey_0 Amplitude (0-100) = '); phase = input('Input phase between Y and Z E components as a fraction of the wavelength (Eg.: -0.25)= '); phase = 2*pi*phase; k = 2*pi/lambda; %wave vector c = 1; % speed of light %xin = starting point for graph xin = 0; %zfi = ending point for graph xfi = 1000; x=xin:(xfi-xin)/1000:xfi; %1000 plot points %This is to set the axes xaxis = x*0; yaxis = x*0; zaxis = x*0; for t = 1:300 clf; hold on; %Creating the E vector Ez=Ez_0*cos(k*x - w*t); %Ez in z^ direction; propagating in x direction - this is a 1D vector Ey=Ey_0*cos(k*x - w*t + phase); %Ey in y^ direction; propagating in x direction - this is a 1D vector % note the phase term. E_tot = [0 Ey Ez]; % E_tot is a vector representing the E field but in MatLab, this is a matrix. %plot3(x, yaxis, zaxis); % Plot propagation axis quiver3(0,0, 0,xfi,0,0, 'r') % Plot vector showing propagation of light % Plot EM wave plot3(x, Ey, Ez); % Plot E field quiver3(0, 0, 0, 0, Ey(1), Ez(1), 'b'); %Electric Field vector %This just sets the axes and initial view axis([0, xfi, -100, 100, -100, 100]) %axis square; view(-37.5+68, 30) axis on grid on %0hold on %Label graph title('EM ray propagating along the X axis.') xlabel('Distance in nanometers (X axis)') ylabel('E Field (Y axis)') zlabel('E field (Z axis)') M(t) = getframe; end %To replot function with different phases: ch= input('Press 1 to continue, 2 to clear graph and 0 to exit: '); if ch == 0 break; elseif ch == 2 hold off; else % end end