#### ihsan7gs

MB Üyesi
Matlab kodundan oluşturulmuş bir grafiği simulink'te disturtion olarak atamak istiyorum. Bu konuda yardımcı olabilecek var mı acaba?
code:

L=100; %surface length
N=128; %fft points
delx= L/N; %shortest wavelength that can be resolved
kf= 2*pi/L; %fundamental spatial freq.
kny= (N/2)*kf; %the highest freq. sampled

k= linspace(-kny/2,kny/2,N);

alpha = 0.0081; %constant
beta = 0.74; %constant
V = 10; % wind speed m/s
g = 9.81; % m/s^2

S = []; %preallocation for PM spectrum
z0= []; %preallocation for wave profile
z = [];

%loop for PM spectrum and wave profile
for i=1:length(k)
S(i)= (alpha/(2k(i)^3))exp(-beta(g/k(i))(g/k(i))*1/(V^4)); %PM spectrum
rho = randn;
sig = randn;
z0(i) = (1/sqrt(2))(rho + 1isig).sqrt(0.5S(i)*kf); %wave profile
z(i) = (1/sqrt(2))*(z0(i) + conj(z0(i)));
end

Z=ifft(z); %inverse dft for extracting surface elevations

%plot random surface wave
figure,
plot(linspace(0,L,N),real(Z))
axis([0,L,-0.015,0.015]);
xlabel('distance (m)');
ylabel('surface elevation (m)');
out= sprintf('1D random sea surface V= %g m/sec at 19.5m and L= %g m',V,L);
title(out);