function etadot = etadot(p,x,t)
% eta Return wave amplitude as a function of position and time.

k = (2*pi*p.freq).^2/p.g;
H = (2*p.spectrum*p.df).^0.5;

etadot = H(1)*p.beta*2*pi*p.freq(1)*sin(k(1)*x - p.beta*2*pi*p.freq(1)*t + p.phases(1));  %Rate

for i = 2:length(p.freq)
etadot = etadot +  H(i)*p.beta*2*pi*p.freq(i)*sin(k(i)*x - p.beta*2*pi*p.freq(i)*t + p.phases(i));
end

if(p.tau > 0)
  for j = 1:length(etadot)
    etadot(j) = etadot(j).*(1-exp(-t(j)/p.tau));
  end
end

end