% open day demonstrations - 1

% moving waves

% k1  l1  om1  k2  l2  om2
% 1    1   20  1.2   0  20   as earlier: stationary pattern
% 1    1   20  1.2   0  16   as earlier: pattern goes leftwards
% 1    1   20  1.2   0  24   as earlier: pattern moves rightwards

% 1  0.1   20  1.2 -0.1 16   pattern moves SW
% 1  0.1   20  1.2 -0.1 24   pattern moves NE

clear

k1     = 1.0  ; 
l1     = 0.05  ; 
omega1 = 20.0   ; 
c1 = omega1/k1 
k2     = 1.2  ; 
l2     = -0.05  ; 
omega2 = 21.0   ; 
c2 = omega2/k2 

xhi=8*pi ;
x = -xhi:0.1*pi:xhi ; 
y = x ; 
[xx,yy] = meshgrid(x,y) ; 
tstep = 0.01 ; 
nsteps = 200 ; 

for i = 1:nsteps 
    
    t = i*tstep ; 
    h1 = sin ( k1*xx + l1*yy - omega1*t ) ;
    h2 = sin ( k2*xx + l2*yy - omega2*t ) ;
    h = 0.5*(h1+h2) ; 
    
    subplot(2,2,1)
    image(x,y,64*h1)
    colormap(jet)
    title('wave 1')
    subplot(2,2,2)
    image(x,y,64*h2)
    title('wave 2')
    subplot(2,2,3)
    image(x,y,64*h)
    title('wave 1 + wave 2')
    mov(i) = getframe ; 
end

%move(mov, 1) 