diff --git a/src/index.org b/src/index.org new file mode 100644 index 0000000..5db990b --- /dev/null +++ b/src/index.org @@ -0,0 +1,78 @@ +#+TITLE: Matlab Function useful for the analysis + +* voltageToVelocityL22 + :PROPERTIES: + :header-args:matlab+: :tangle voltageToVelocityL22.m + :header-args:matlab+: :comments none :mkdirp yes + :header-args:matlab+: :eval no :results none + :END: + <> + +This Matlab function is accessible [[file:voltageToVelocityL22.m][here]]. + +#+begin_src matlab + function [velocity] = voltageToVelocityL22(voltage, time, gain) + % voltageToVelocityL22 - + % + % Syntax: [velocity] = voltageToVelocityL22(voltage, time, gain) + % + % Inputs: + % - voltage - Measured voltage + % - time - Time vector + % - gain - Gain of the voltage amplifier in dB + % + % Outputs: + % - velocity - +#+end_src + +#+begin_src matlab + s = zpk('s'); +#+end_src + +#+begin_src matlab + S0 = 88; % Sensitivity [V/(m/s)] + f0 = 2; % Cut-off frequnecy [Hz] + + S = S0*(s/2/pi/f0)/(1+s/2/pi/f0); +#+end_src + +#+begin_src matlab + velocity = lsim((S*10^(gain/20))\1, voltage, time); +#+end_src + +* voltageToDisplacementL22 + :PROPERTIES: + :header-args:matlab+: :tangle voltageToDisplacementL22.m + :header-args:matlab+: :comments none :mkdirp yes + :header-args:matlab+: :eval no :results none + :END: + <> + +This Matlab function is accessible [[file:voltageToDisplacementL22.m][here]]. + +#+begin_src matlab + function [disp] = voltageToDisplacementL22(voltage, time, gain) + % voltageToDisplacementL22 - + % + % Syntax: [disp] = voltageToDisplacementL22(voltage, time, gain) + % + % Inputs: + % - voltage - Measured voltage + % - time - Time vector + % - gain - Gain of the voltage amplifier in dB + % + % Outputs: + % - disp - +#+end_src + +#+begin_src matlab + s = zpk('s'); +#+end_src + +#+begin_src matlab + voltage = voltage - mean(voltage); + + velocity = voltageToVelocityL22(voltage, time, gain); + + disp = lsim(1/s, velocity, time); +#+end_src diff --git a/src/voltageToDisplacementL22.m b/src/voltageToDisplacementL22.m new file mode 100644 index 0000000..d389820 --- /dev/null +++ b/src/voltageToDisplacementL22.m @@ -0,0 +1,20 @@ +function [disp] = voltageToDisplacementL22(voltage, time, gain) +% voltageToDisplacementL22 - +% +% Syntax: [disp] = voltageToDisplacementL22(voltage, time, gain) +% +% Inputs: +% - voltage - Measured voltage +% - time - Time vector +% - gain - Gain of the voltage amplifier in dB +% +% Outputs: +% - disp - + +s = zpk('s'); + +voltage = voltage - mean(voltage); + +velocity = voltageToVelocityL22(voltage, time, gain); + +disp = lsim(1/s, velocity, time); diff --git a/src/voltageToVelocityL22.m b/src/voltageToVelocityL22.m new file mode 100644 index 0000000..4e89cb1 --- /dev/null +++ b/src/voltageToVelocityL22.m @@ -0,0 +1,21 @@ +function [velocity] = voltageToVelocityL22(voltage, time, gain) +% voltageToVelocityL22 - +% +% Syntax: [velocity] = voltageToVelocityL22(voltage, time, gain) +% +% Inputs: +% - voltage - Measured voltage +% - time - Time vector +% - gain - Gain of the voltage amplifier in dB +% +% Outputs: +% - velocity - + +s = zpk('s'); + +S0 = 88; % Sensitivity [V/(m/s)] +f0 = 2; % Cut-off frequnecy [Hz] + +S = S0*(s/2/pi/f0)/(1+s/2/pi/f0); + +velocity = lsim((S*10^(gain/20))\1, voltage, time);