Where is the problem? I couldnt find it.
Show older comments
I'm investigating into wave statistics derived from records in time and frequency domain. I used the Bretschneider Spectrum Formula in order to create linear waves. I created 400 linear waves and I sumed of them. In that case irregular wave was created. I defined the exact time domain (1258 s). After I used the Fourier Transform for getting spectral density. I think my results are enough for now. But mine spectra and Bretschneider spectra dont fix. Where is the problem? I cant understand. Please, I need help !!!
clc,clear,close all
%PARAMETERS%
t1=1258; %Exact Time Domain
wn=400; %Wave Number , components
SS=8; %Sea State
%STRUCTURE%
for i=1:400
Q=2*pi.*(rand(1,wn)); %Phase
end
t=transpose([0:0.1:t1]);
w1=2/wn;
w=[0.005:w1:2];
if SS==8 %Sea State 8
Tm=16.4; %Modal Period
Hs=11.5; %Significant Wave Height
scale=0.275; %Scale
end
if SS==6 %Sea State 6
Tm=12.4; %Modal Period
Hs=5; %Significant Wave Height
scale=0.1; %Scale
end
if SS==4 %Sea State 4
Tm=8.8; %Modal Period
Hs=1.9; %Significant Wave Height
scale=0.0321; %Scale
end
Wm=2*pi/Tm; %Modal Frequency
%Bretschneider Spectrum%
S=(5.*(Wm.^4))./(16.*(w.^5)).*(Hs.^2).*exp((-5.*(Wm.^4))./(4.*(w.^4)));
a=transpose(sqrt(S.*2*w1)); %Amplitude
d=sin(t*w+Q)*a; %irregular wave
grid
plot(t,d)
%FOURIER%
spk=fft(d); %fourier transform%
spkg=abs(spk); %magnitude of fft%
figure; plot(fftshift(spkg))
figure; plot(2*fftshift(spkg)/t1)
fr=[-50:100/(t1*10):50]; %sizing%
X=(fr/2+0.1); %frequency%
Y=(2*fftshift(spkg)/t1); %spectral density%
grid
plot(X,Y)
xlim([0,2]);
%SMOOTHING%
windowSize = 21; % Decrease for less smoothing, increase for more smoothing.
Y = conv(Y*scale, ones(windowSize, 1), 'same');
figure;
grid
plot(X,Y)
title('Smoothed Y', 'FontSize', 20);
xlim([0, 2]);
drawnow
%CHECK THE RESULT%
wk=[0.01:0.01:2];
S1=(5.*(Wm.^4))./(16.*(wk.^5)).*(Hs.^2).*exp((-5.*(Wm.^4))./(4.*(wk.^4)));
grid
plot(X,Y,wk,S1)
xlim([0, 2]);
%Calculating Areas%
hold on
Mine_Spectrum=trapz(X,Y)
Brts_Spectrum=trapz(wk,S1)
hold off
3 Comments
KALYAN ACHARJYA
on 17 May 2018
Edited: KALYAN ACHARJYA
on 17 May 2018
Any code error?
Gurkan Yilmaz
on 17 May 2018
KALYAN ACHARJYA
on 17 May 2018

Answers (1)
KALYAN ACHARJYA
on 17 May 2018
0 votes
In line, 32 t and w have different length, for multiplication both vector length should be same, the same case for 'a' too. For multiplication, vector dimension should be same.

3 Comments
Gurkan Yilmaz
on 17 May 2018
KALYAN ACHARJYA
on 17 May 2018
your code having an error, how you got the results.
Gurkan Yilmaz
on 17 May 2018
Categories
Find more on Smoothing and Denoising 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!