%Program to demonstrate some properties and symmetries of Waves
%Probably used in Lab for Optics.
%Version D. W. Donovan 2004-01-15
clear all;
A=10.0;%Define Amplitude of wave
p0=0.0;%Define Initial Phase Angle of wave
T=1.0;%Define Period of wave
L=1.0;%Define Wavelength of wave
t1=[0*T:.01*T:3*T]';%Range of time in units of Period (T)
x1=[0*L:.01*L:3*L]';%Range of distance in units of Wavelength (L)
w=2*pi/T;
k=2*pi/L;

y1=A*sin(k*x1+p0);
y2=A*sin(-w*t1+p0);
[x,t]=meshgrid(x1,t1);
y=A*sin(k*x-w*t+p0);

figure
mesh(x,t,y)
xlabel('x,(units of \lambda)')
ylabel('t, (units of T)')
zlabel('\psi(x,t)')
tt0='\newline';
tt1='Plot of \psi(x,t) in both position and time';
tt2='D. W. Donovan - ';
tf=[tt1,tt0,tt2,date];
title(tf)

figure
plot(x1,y1,'r')
xlabel('x,(units of \lambda)')
ylabel('\psi(x,0)')
tt3='Plot of \psi(x,0) vs position (Wave Profile)';
tf2=[tt3,tt0,tt2,date];
title(tf2)

figure
plot(t1,y2)
xlabel('t, (units of T)')
ylabel('\psi(0,t)')
tt4='Plot of \psi(0,t) vs time (Behavior of x=0 point over time)';
tf3=[tt4,tt0,tt2,date];
title(tf3)