Where is the problem? I couldnt find it.

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

KALYAN ACHARJYA
KALYAN ACHARJYA 2018년 5월 17일
편집: KALYAN ACHARJYA 2018년 5월 17일
Any code error?
Gurkan Yilmaz
Gurkan Yilmaz 2018년 5월 17일
there arent any code error.
KALYAN ACHARJYA
KALYAN ACHARJYA 2018년 5월 17일

댓글을 달려면 로그인하십시오.

답변 (1개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2018년 5월 17일

0 개 추천

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

Gurkan Yilmaz
Gurkan Yilmaz 2018년 5월 17일
Actually my problem is that Bretschneider Spectrum and mine spectrum are not same and also their graphs areas are different :( if you start the system, you can see the results easily and you can understand my problem maybe.
KALYAN ACHARJYA
KALYAN ACHARJYA 2018년 5월 17일
your code having an error, how you got the results.
Gurkan Yilmaz
Gurkan Yilmaz 2018년 5월 17일
I copied my sharing and I started again, There is no error :D

댓글을 달려면 로그인하십시오.

질문:

2018년 5월 16일

댓글:

2018년 5월 17일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by