clg clear echo on clc %--------------------------- Waves.m ----------------------- % % Propagation and Interference of Waves % % % Lecture 5 % Chemistry 455 % Summer Quarter 1995 % James B. Callis, Instructor % % % Press any key to continue pause clc % Now let us generate the spatial profile % of a traveling wave viewed at a sequence of times % using MATLAB. Let us do this for the electric field % of electromagnetic radiation of amplitude unity whose % wavelength is 500 nm. We will display the wave as amplitude % vs. spatial position from 0 to 950 nm in steps % of 50 nm. % % % Press any key to continue pause clc % Here are the constants: c = 3.00e8; % Speed of light in m/sec lam = 500e-9;% Wavelength of light, m Dx = 50e-9; % Spatial Increment, m L = 950e-9; % max spatial dimension, m freq = c/lam; % frequency of light Dt = 1/(20*freq); % Increment of time % % Now make up the time and space vectors: x = 0:Dx:L; % look over 950 nm t = 0:Dt:5/freq; % go over 5 cycles % Press any key to continue pause clc % Now calculate the mesh grid [X,T] = meshgrid(x,t); % Always use mesh grid to synthesize 2-D % Data % Now calculate all of the time - space points u = sin(2*pi*(freq*T-X/lam)); % No dot operators needed pause % Press any key to make a movie style plot for i = 1:length(t) plot(x,u(i,:)) title('Movie of a Traveling Sine Wave') xlabel('Spatial Position, m') ylabel('Amplitude (Arbitrary Units)') pause(.1) end % Press any key to continue pause clc % Let us now consider how a wave traveling from the left % and reflecting from the x=0 position could interfere with % itself and cause a standing wave with stable node positions. % Here is the wave traveling to the left: u_left = sin(2*pi*(freq*T+X/lam)); % No dot operators needed % Here is the wave that is reflected, inverted and traveling % to the right: u_right = -sin(2*pi*(freq*T-X/lam)); % No dot operators needed % Here is the sum wave, which has stable nodes: u_sum = u_left + u_right; pause % Press any key to make a movie style plot for i = 1:length(t) plot(x,u_left(i,:),x,u_right(i,:),x,u_sum(i,:)) axis([0 1e-6 -2 2]) title('Movie of a Stationary Sine Wave') xlabel('Spatial Position, m') ylabel('Amplitude (Arbitrary Units)') pause(.1) end pause % Press any key to see all of the sum waves on one graph pause clg plot(x,u_sum) axis([0 1e-6 -2 2]) title('Snapshots of a Stationary Sine Wave') xlabel('Spatial Position, m') ylabel('Amplitude (Arbitrary Units)')