Revision 168
(checked in by cbc, 16 years ago)
|
Adding diwasp customizations.
|
Line | |
---|
1 |
function eta=makerandomsea(eamp,wns,dirs,xx,yy) |
---|
2 |
|
---|
3 |
%makerandomsea: make random sea surface elevation |
---|
4 |
% |
---|
5 |
%[eta] = makerandomsea(eamp,wns,dirs,xx,yy) |
---|
6 |
% |
---|
7 |
%outputs: |
---|
8 |
%eta output surface elevation |
---|
9 |
% |
---|
10 |
%inputs: |
---|
11 |
%eamp matrix of the component amplitudes [i,j] with i'th frequency component and j'th directional component |
---|
12 |
%wns column vector of component wavenumbers in m-1. These must correspond to the frequency bins in input eamp |
---|
13 |
%dirs row vector of component directions in rads. These must correspond to the directional bins in input eamp |
---|
14 |
%xx row vector of x direction grid spacing |
---|
15 |
%yy column vector of y direction grid spacing |
---|
16 |
% |
---|
17 |
%amplitude matrix must be [m by n] where m is number of wavenumber |
---|
18 |
%components in wns and n is number of directional components in dirs |
---|
19 |
% |
---|
20 |
|
---|
21 |
|
---|
22 |
disp('calculating sea surface elevation'); |
---|
23 |
|
---|
24 |
nx=size(xx,2); |
---|
25 |
ny=size(yy,2); |
---|
26 |
|
---|
27 |
randphase=8*atan(1.0)*rand(size(eamp)); |
---|
28 |
|
---|
29 |
for i=1:nx |
---|
30 |
for j=1:ny |
---|
31 |
eta(i,j)=sum(sum(eamp.*cos(xx(i)*wns*cos(dirs)+yy(j)*wns*sin(dirs)+randphase))); |
---|
32 |
end |
---|
33 |
end |
---|
34 |
|
---|
35 |
|
---|