From 0e89b61da5a71529c6794b588413fc09b19471b3 Mon Sep 17 00:00:00 2001 From: Mathew Topper Date: Mon, 16 Nov 2020 12:43:29 +0000 Subject: [PATCH] Ensure random phases are selected from range [0, 2pi] (#202) Co-authored-by: Ryan Coe --- examples/RM3/simulateDevice.m | 4 ++-- examples/WaveBot/simulateDevice.m | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/RM3/simulateDevice.m b/examples/RM3/simulateDevice.m index dbe1ce1..9935a6f 100644 --- a/examples/RM3/simulateDevice.m +++ b/examples/RM3/simulateDevice.m @@ -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); @@ -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; diff --git a/examples/WaveBot/simulateDevice.m b/examples/WaveBot/simulateDevice.m index 92df7ca..430c5d7 100644 --- a/examples/WaveBot/simulateDevice.m +++ b/examples/WaveBot/simulateDevice.m @@ -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); @@ -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