matlab does not plot the time series
Show older comments
Hello everyone,
I am trying to generate velocity from JONSWAP spectrum.However, when the depth of is higher than 20 m, MATLAB does not plot anything
I did not succeed to figure out the problem. The code is the following:
x=0;
depth=50;
mean_wind_speed=11.5;
gamma_jonswap=3.3;
f_p=0.208;
Tp=1/f_p;
t=linspace(0,1000,5000);
fs=length(t)/t(end);
delta_f=fs/length(t); % frequency step
g=9.81; % gravity
f=linspace(1e-3,(fs-delta_f)/2,length(t));
fetch=40e+3;
alpha_p=0.076*(fetch*g/(mean_wind_speed)^2)^(-0.22);
k=(2*pi*f).^2/g; % wave number
sigma_jonswap=zeros(1,length(f));
for j=1:length(f)
if f(j)<=f_p
sigma_jonswap(j)=0.07;
else
sigma_jonswap(j)=0.09;
end
end
pm_spectrum= alpha_p*g^2*(2*pi)^(-4).*f.^(-5).*exp(-(5/4)*(f_p./f).^4);
jonswap_spectrum=pm_spectrum.*gamma_jonswap.^exp(-((f-f_p*ones(1,length(f))).^2)./((2*sigma_jonswap.^2).*((f_p*ones(1,length(f))).^2)));
a=sqrt(2*jonswap_spectrum*delta_f);
phi=2*pi*rand(1,length(a));
%% velocity from JONSWAP spectrum
velocity_jonswap=zeros(1,length(t));
for j=1:length(t)
velocity_jonswap(j)=sum(2*pi*f.*(cosh(k*(depth))./(Tp*sinh(k*depth))).*a.*sin(k*x-2*pi*f*t(j)+phi));
end
figure(1)
plot(t,velocity_jonswap)
xlabel('time(s)')
ylabel('velocity of the wave')
title('velocity of the wave generated using JONSWAP spectrum at z=0 and x=0')
grid on
Could anyone help ?
Best Regards
Accepted Answer
More Answers (0)
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!