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. .
조회 수: 3 (최근 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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!