# What is the Shape of the Spectrum?

3 views (last 30 days)
Hello Guys!!!
I'm trying to solve Q1 and Q2 in the attached document 'PracticalWork_1920.pdf '.
dt is the duration of each wave (ai,fi) to reach the final location. How can I compute the location in order to plot the shape of the spectrum at the location?
This is my code so far. Can anyone help me?
clc
clear all
close all
myData = importdata('bathymetry.dat');
x = myData(:,1);
z = myData(:,2);
%Plot data
figure(1)
plot(x,z,'b')
grid on
axis tight
xlabel ('Longitude {\circ}')
ylabel ('Water depth (m)')
title('Bathymetry Profile')
%%
%Fully-developed sea
load('FDS.mat') %range from -40 to -2.4(the observer)
longitude = FDS(:,1);
depth = -FDS(:,2);
figure(2);
plot(longitude,-depth);
grid on
axis tight
xlabel ('Longitude {\circ}')
ylabel ('Water depth (m)')
title('Fully-Developed Sea Profile')
%Constant variable
gravity = 9.81; %m/s^2
% Define the frequency vector
Tmin = 3;
Tmax = 30;
nFreq = 30;
fmin = 1/Tmax;
fmax = 1/Tmin;
f = linspace(fmin,fmax,nFreq);
% Define JONSWAP spectrum parameters
Hs = 5; % in m
Tp = 20; % in s
gam = 3; % gamma factor is always greater than 1
%%
% In this function, f=0 should be excluded
S = JONSWAP_spectrum(f,Hs,Tp,gam);
%
figure(3);
plot(f,S)
xlabel('Frequency (Hz)')
ylabel('Wave spectrum in (m^2/s)')
title('The JONSWAP Spectrum')
%set(findall(gcf, '-property', 'FontSize'), 'FontSize', 14)
%}
%%
% Decomposition of the wave spectrum into regular waves
% The row of dt is 30
nWaves = numel(f);
df = f(2) - f(1);
for i = 1:nWaves
a(i,1) = sqrt(2*S(i)*df);
omega(i,1) = 2*pi*f(i);
k(i,1) = kfromw(omega(i,1), depth(1), gravity);
cg(i,1) = 0.5*omega(i,1)/k(i); % check the 1/2 in the formula
xg(i,1) = 0; % Initial position
dt(i,1) = 0; % Initial position
end
%%
% Evolution equations
% The column of dt is 2257
ndepth = size(FDS,1);
for it = 2:ndepth %(in hours)
for i = 1:nWaves
a(i,it) = a(i,1); % no dissipation / dispersion
omega(i,it) = omega(i,1); % the frequency is not changed
k(i,it) = kfromw(omega(i,it), depth(it),gravity); % Wave number associated with depth
cg(i,it) = 0.5*omega(i,1)/k(i,it); % group velocity
dtheta = (longitude(it)-longitude(it-1))/180*pi;
dt(i,it) = dx/cg(i,it);
end
end