From d5a1cbdaeae54eeca2b75afc6d58bf990bd89c06 Mon Sep 17 00:00:00 2001 From: Thomas Dehaeze Date: Tue, 21 Jan 2020 15:46:34 +0100 Subject: [PATCH] Add parameter to enable/disable all disturbances --- simscape_subsystems/index.org | 14 ++++++++------ src/initDisturbances.m | 14 ++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/simscape_subsystems/index.org b/simscape_subsystems/index.org index 37f0eef..7a9a4af 100644 --- a/simscape_subsystems/index.org +++ b/simscape_subsystems/index.org @@ -304,6 +304,8 @@ This Matlab function is accessible [[file:src/initDisturbances.m][here]]. *** Optional Parameters #+begin_src matlab arguments + % Global parameter to enable or disable the disturbances + args.enable logical {mustBeNumericOrLogical} = true % Ground Motion - X direction args.Dwx logical {mustBeNumericOrLogical} = true % Ground Motion - Y direction @@ -355,7 +357,7 @@ We define some parameters that will be used in the algorithm. #+end_src #+begin_src matlab - if args.Dwx + if args.Dwx && args.enable theta = 2*pi*rand(N/2,1); % Generate random phase [rad] Cx = [0 ; C.*complex(cos(theta),sin(theta))]; Cx = [Cx; flipud(conj(Cx(2:end)))];; @@ -366,7 +368,7 @@ We define some parameters that will be used in the algorithm. #+end_src #+begin_src matlab - if args.Dwy + if args.Dwy && args.enable theta = 2*pi*rand(N/2,1); % Generate random phase [rad] Cx = [0 ; C.*complex(cos(theta),sin(theta))]; Cx = [Cx; flipud(conj(Cx(2:end)))];; @@ -377,7 +379,7 @@ We define some parameters that will be used in the algorithm. #+end_src #+begin_src matlab - if args.Dwy + if args.Dwy && args.enable theta = 2*pi*rand(N/2,1); % Generate random phase [rad] Cx = [0 ; C.*complex(cos(theta),sin(theta))]; Cx = [Cx; flipud(conj(Cx(2:end)))];; @@ -389,7 +391,7 @@ We define some parameters that will be used in the algorithm. *** Translation Stage - X direction #+begin_src matlab - if args.Fty_x + if args.Fty_x && args.enable phi = dist_f.psd_ty; % TODO - we take here the vertical direction which is wrong but approximate C = zeros(N/2,1); for i = 1:N/2 @@ -407,7 +409,7 @@ We define some parameters that will be used in the algorithm. *** Translation Stage - Z direction #+begin_src matlab - if args.Fty_z + if args.Fty_z && args.enable phi = dist_f.psd_ty; C = zeros(N/2,1); for i = 1:N/2 @@ -425,7 +427,7 @@ We define some parameters that will be used in the algorithm. *** Spindle - Z direction #+begin_src matlab - if args.Frz_z + if args.Frz_z && args.enable phi = dist_f.psd_rz; C = zeros(N/2,1); for i = 1:N/2 diff --git a/src/initDisturbances.m b/src/initDisturbances.m index 8d68c19..0e8e0f1 100644 --- a/src/initDisturbances.m +++ b/src/initDisturbances.m @@ -7,6 +7,8 @@ function [] = initDisturbances(args) % - args - arguments + % Global parameter to enable or disable the disturbances + args.enable logical {mustBeNumericOrLogical} = true % Ground Motion - X direction args.Dwx logical {mustBeNumericOrLogical} = true % Ground Motion - Y direction @@ -42,7 +44,7 @@ for i = 1:N/2 C(i) = sqrt(phi(i)*df); end -if args.Dwx +if args.Dwx && args.enable theta = 2*pi*rand(N/2,1); % Generate random phase [rad] Cx = [0 ; C.*complex(cos(theta),sin(theta))]; Cx = [Cx; flipud(conj(Cx(2:end)))];; @@ -51,7 +53,7 @@ else Dwx = zeros(length(t), 1); end -if args.Dwy +if args.Dwy && args.enable theta = 2*pi*rand(N/2,1); % Generate random phase [rad] Cx = [0 ; C.*complex(cos(theta),sin(theta))]; Cx = [Cx; flipud(conj(Cx(2:end)))];; @@ -60,7 +62,7 @@ else Dwy = zeros(length(t), 1); end -if args.Dwy +if args.Dwy && args.enable theta = 2*pi*rand(N/2,1); % Generate random phase [rad] Cx = [0 ; C.*complex(cos(theta),sin(theta))]; Cx = [Cx; flipud(conj(Cx(2:end)))];; @@ -69,7 +71,7 @@ else Dwz = zeros(length(t), 1); end -if args.Fty_x +if args.Fty_x && args.enable phi = dist_f.psd_ty; % TODO - we take here the vertical direction which is wrong but approximate C = zeros(N/2,1); for i = 1:N/2 @@ -84,7 +86,7 @@ else Fty_x = zeros(length(t), 1); end -if args.Fty_z +if args.Fty_z && args.enable phi = dist_f.psd_ty; C = zeros(N/2,1); for i = 1:N/2 @@ -99,7 +101,7 @@ else Fty_z = zeros(length(t), 1); end -if args.Frz_z +if args.Frz_z && args.enable phi = dist_f.psd_rz; C = zeros(N/2,1); for i = 1:N/2