close all
clear all

g = 9.81;

f = [.05 .075 .1 .15];
w = 2*pi*f;

k = (w.^2)/g;
lambda = 2*pi./k;

z = 0:-1:-100;

for i = 1:length(f);
 V(i,:) = exp(k(i).*z); 
end

plot(100*V,z)
legend('f = 0.05Hz','f = 0.075Hz','f = 0.1Hz','f = 0.15Hz','Location','SouthEast');
xlabel('% of Surface Velocity');
ylabel('Depth (m)');

print('-dpdf','VelocityDefect');

h = 50;
z = 0:-1:-h;

for i = 1:length(f)
  w_fd = w(i);

  k_fd(i) = fzero(@(kk) DispRelation(kk,w_fd,h,g),k(i));
  V_fdz(i,:) = sinh(k_fd(i)*(z+h))/cosh(k_fd(i)*h); 
  V_fdu(i,:) = cosh(k_fd(i)*(z+h))/cosh(k_fd(i)*h); 

  V_fdz(i,:) = V_fdz(i,:)/V_fdz(i,1);
end



figure
plot(100*V_fdz,z)
legend('f = 0.05Hz','f = 0.075Hz','f = 0.1Hz','f = 0.15Hz','Location','SouthEast');
xlabel('% of Surface Velocity');
ylabel('Depth (m)');
title('Decay of Vertical Velocity of Finite Depth Waves in 60m water');
print('-dpdf','VerticalVelocityDefect_FD');

figure
plot(100*V_fdu,z)
legend('f = 0.05Hz','f = 0.075Hz','f = 0.1Hz','f = 0.15Hz','Location','SouthEast');
xlabel('% of Surface Velocity');
ylabel('Depth (m)');