Skip to content

Commit

Permalink
Ensure random phases are selected from range [0, 2pi] (#202)
Browse files Browse the repository at this point in the history
Co-authored-by: Ryan Coe <[email protected]>
  • Loading branch information
H0R5E and ryancoe authored Nov 16, 2020
1 parent be7f353 commit 0e89b61
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions examples/RM3/simulateDevice.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
waveAmp = sqrt(2 * dw * s);

% Row vector of random phases?
ph = rand(length(s), 1);
ph = rand(length(s), 1) * 2 * pi;

% Wave height in frequency domain
eta_fd = waveAmp .* exp(1i*ph);
Expand Down Expand Up @@ -201,7 +201,7 @@

% Add phase realizations
n_ph_avg = 5;
ph_mat = 2 * pi * rand(length(motion.w), n_ph_avg);
ph_mat = [motion.ph, rand(length(motion.w), n_ph_avg-1) * 2 * pi];
n_ph = size(ph_mat, 2);

freq = motion.W;
Expand Down
4 changes: 2 additions & 2 deletions examples/WaveBot/simulateDevice.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
waveAmp = interp1(SS.w, waveAmpSS, w, interpMethod, 'extrap');

% Row vector of random phases
ph = rand(size(waveAmp));
ph = rand(size(waveAmp)) * 2 * pi;

% Wave height in frequency domain
eta_fd = waveAmp .* exp(1i * ph);
Expand Down Expand Up @@ -226,7 +226,7 @@

% Add phase realizations
n_ph = 5;
ph_mat = [dynModel.ph, rand(length(dynModel.w), n_ph-1)];
ph_mat = [dynModel.ph, rand(length(dynModel.w), n_ph-1) * 2 * pi];

for ind_ph = 1 : n_ph

Expand Down

0 comments on commit 0e89b61

Please sign in to comment.