|
1 | 1 | function wave_elevation = surface_elevation(S, time_index, options) |
2 | 2 |
|
3 | 3 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
4 | | -% |
5 | | -% Generate wave surface elevation from spectrum |
| 4 | +% Calculates wave elevation time-series from spectrum |
6 | 5 | % |
7 | 6 | % Parameters |
8 | 7 | % ------------ |
9 | 8 | % S: structure |
10 | 9 | % Spectral data with fields: |
11 | | -% S.spectrum: (n_freq x 1) spectral density values (m^2/Hz) |
12 | | -% S.frequency: (n_freq x 1) frequency vector (Hz) |
| 10 | +% S.spectrum: (n_freq x 1) spectral density [m^2/Hz] |
| 11 | +% S.frequency: (n_freq x 1) frequency vector [Hz] |
13 | 12 | % |
14 | 13 | % time_index: vector |
15 | | -% (n_time x 1) time vector (s) |
| 14 | +% Time used to create the wave elevation time-series [s], |
| 15 | +% for example, time = 0:0.01:100 |
16 | 16 | % |
17 | 17 | % options: structure (optional) |
18 | 18 | % Optional fields: |
19 | | -% seed: random seed (default = 123) |
20 | | -% frequency_bins: bin widths for each frequency |
21 | | -% phases: explicit phases (radians) |
22 | | -% method: 'ifft' (default) or 'sum_of_sines' |
| 19 | +% seed: Random seed (default = 123) |
| 20 | +% frequency_bins: Bin widths for frequency of S. Required for unevenly sized bins |
| 21 | +% phases: Explicit phases for frequency components (overrides seed) |
| 22 | +% for example, phases = rand(length(S.frequency),1) * 2 * pi |
| 23 | +% method: Method used to calculate the surface elevation. 'ifft' |
| 24 | +% (Inverse Fast Fourier Transform) used by default if the |
| 25 | +% given frequency_bins==[] or is evenly spaced. |
| 26 | +% 'sum_of_sines' explicitly sums each frequency component |
| 27 | +% and used by default if uneven frequency_bins are provided. |
| 28 | +% The 'ifft' method is significantly faster. |
23 | 29 | % |
24 | 30 | % Returns |
25 | 31 | % --------- |
26 | 32 | % wave_elevation: structure |
27 | 33 | % Generated wave elevation with fields: |
28 | | -% elevation: (n_time x 1) wave elevation (m) |
29 | | -% time: time vector (s) |
| 34 | +% elevation: Wave surface elevation [m] |
| 35 | +% time: time vector [s] |
30 | 36 | % type: description string |
31 | | -% |
32 | | -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 37 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
33 | 38 |
|
34 | 39 | arguments |
35 | 40 | S struct |
|
0 commit comments