Naik-turun permukaan laut pada satu titik pengamatan diukur setiap 0.05 detik selama +- 400 detik, sebagaimana pada plot di bawah ini.
Script MATLAB:
% Generate Sea waves
dt = 0.05;
npts = 8192;
nptso2 = npts/2;
tr = dt*npts; % dt * 8192 for 8192 total points
t = 0:dt:(tr-dt);
tp4 = (2*pi)^4;
g = 9.81;
v = 15;
df = 1/tr;
ffold = df*nptso2; % df*4096 for 8192 total points
f = 0:df:ffold;
f = f+eps;
fac1 = 0.0081*g*g/tp4;
fac2 = 0.74*(g/v)^4/tp4;
s = 0.5*fac1./f.^5.*exp(-fac2./f.^4);
rand('state',sum(100*clock));
p = 2*pi*rand(1,nptso2);
p(nptso2+1) = 0;
z = exp(i*p).*sqrt(s*df);
y = abs(z);
% FFT
zt = [z conj(fliplr(z(2:4096)))];
zeta = real(fft(zt));
% Plot Sea Wave
figure
plot(t,zeta,'LineWidth',1)
set(gca,'FontSize',12);
xlabel('Waktu (detik)');
ylabel('Kenaikan Permukaan (m)');
title('Gelombang Laut pada Satu Titik','FontWeight','normal');
% Plot Magnitude Spectra
[maxval,idx] = max(y);
figure
plot(f,abs(z),'LineWidth',1); hold on
text(f(idx),maxval,[' f peak = ',num2str(f(idx)),' Hz'],'FontSize',12)
set(gca,'FontSize',12);
xlabel('Frekuensi (Hz)')
ylabel('Magnitud');
title('Spektrum Magnitud Gelombang Laut','FontWeight','normal');
No comments:
Post a Comment