This is my code to generate random time series and to plot it. I want my code to do the same operations n times and then average Yn arrays of different repetitions and give me Yaverage array. I cant figure it out. .

1 次查看(过去 30 天)
close all;
numofrep=input('number of repetitions:');
dw=0.02; %Frequency resolution
w=dw:dw:10; %Frequencies
Hs=1; %Significant wave height
Tp=6; %Peak period
wp=6.28/Tp; %Peak frequency
S=w; %Initialise vector to hold Energy Spectrum
H=w; %Initialise vector to hold Amplitude spectrum
for i =1:length(w)
S(i)=5/16*wp^4/w(i)^5*Hs^2*exp(-1.25*(wp/w(i))^4); %Pierson-Moskowitz Energy Spectrum
H(i)=sqrt(2*S(i)*dw); %Calculate amplitude spectrum from energy spectrum
end
t=0:0.01:200; %Create time vector
Y=t*0; %Initialise Wave height vector
for i =1:length(w)
Y=+H(i)*sin(w(i)*t+rand()*6.28); %Create Wave height time series from amplitude spectrum
end
figure, plot(t,Y);

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Time Series 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by