close all
clear all

rho = 1025;
g = 9.81;

c0 = rho*pi*g/4;

f = 0:.01:.5;
f = f';
alpha = 8.1e-3;
beta = .74;
w = 2*pi*f;

df = f(2)-f(1);

 Hs = 1;
 clear S_Hs;
 for i = 1:length(Hs)
   U19 = sqrt(Hs(i)*g/0.21);
   w0 = g/U19;
   S_Hs(i,:) = 2*pi*(alpha*g^2)*exp(-beta*(w0./w).^4)./(w.^5);
   S_Hs(i,1) = S_Hs(i,2);
 end
 
 figure
 plot(f,S_Hs);
 
 t = 1:.005:200;
 
 zt = spectrum2tseries(f,S_Hs,t);
 
 figure;plot(t,zt);
 
 n_windows = 8;
 [f_recon, Pxx] = tseries2spectrum(t,zt,n_windows);
 
 figure
 plot(f_recon,Pxx,f,S_Hs)
 foo = axis;
 foo(1) = 0;
 foo(2) = f(end);
 axis(foo);
 
 