Surface gravity water waves 167
for m=1:fser
a(m)=0;
a1(m)=0;
for k=1:nt
a(m)=a(m)+x(k)*sin(2*pi*m*(k-1)/nt);
a1(m)=a1(m)+x1(k)*sin(2*pi*m*(k-1)/nt);
end
a(m)=a(m)*2/nt;
a1(m)=a1(m)*2/nt;
end
% Fourier coefficient b;
for m=1:fser
b(m)=0;
b1(m)=0;
for k=1:nt
b(m)=b(m)+x(k)*cos(2*pi*m*(k-1)/nt);
b1(m)=b1(m)+x1(k)*cos(2*pi*m*(k-1)/nt);
end
b(m)=b(m)*2/nt;
b1(m)=b1(m)*2/nt;
end
amax=0;
% Fourier amplitude periodogram;
for m=1:fser
ampl(m)=sqrt(a(m)^2+b(m)^2);
ampl1(m)=sqrt(a1(m)^2+b1(m)^2);
end
plot(1:nt,x,'b','Linewidth',1.0)
xlabel('Time steps x 0.5 [s]');
ylabel('Free surface excitation at mid-point of the basin
[m]')
figure
plot(1:fser,a,'b','Linewidth',1.5);
hold on
plot(1:fser,b,'r','Linewidth',1.5);
xlabel('Wave number of Fourier series terms');
ylabel('Fourier series coefficients at mid-point of the
basin');
legend('Coefficient a','Coefficient b',2);
figure
plot(1:fser,ampl,'b','Linewidth',1.5);
hold on
plot(1:fser,ampl1,'r','Linewidth',1.5);
xlabel('Wave number of Fourier series terms');
ylabel('Amplitude of Fourier components');
legend('Location x=nx/2','Location x=nx/5',2);
text(20,0.0080,'Periodogram')
for m=1:fser
a(m)=0;
a1(m)=0;
for k=1:nt
a(m)=a(m)+x(k)*sin(2*pi*m*(k-1)/nt);
a1(m)=a1(m)+x1(k)*sin(2*pi*m*(k-1)/nt);
end
a(m)=a(m)*2/nt;
a1(m)=a1(m)*2/nt;
end
% Fourier coefficient b;
for m=1:fser
b(m)=0;
b1(m)=0;
for k=1:nt
b(m)=b(m)+x(k)*cos(2*pi*m*(k-1)/nt);
b1(m)=b1(m)+x1(k)*cos(2*pi*m*(k-1)/nt);
end
b(m)=b(m)*2/nt;
b1(m)=b1(m)*2/nt;
end
amax=0;
% Fourier amplitude periodogram;
for m=1:fser
ampl(m)=sqrt(a(m)^2+b(m)^2);
ampl1(m)=sqrt(a1(m)^2+b1(m)^2);
end
plot(1:nt,x,'b','Linewidth',1.0)
xlabel('Time steps x 0.5 [s]');
ylabel('Free surface excitation at mid-point of the basin
[m]')
figure
plot(1:fser,a,'b','Linewidth',1.5);
hold on
plot(1:fser,b,'r','Linewidth',1.5);
xlabel('Wave number of Fourier series terms');
ylabel('Fourier series coefficients at mid-point of the
basin');
legend('Coefficient a','Coefficient b',2);
figure
plot(1:fser,ampl,'b','Linewidth',1.5);
hold on
plot(1:fser,ampl1,'r','Linewidth',1.5);
xlabel('Wave number of Fourier series terms');
ylabel('Amplitude of Fourier components');
legend('Location x=nx/2','Location x=nx/5',2);
text(20,0.0080,'Periodogram')
