#+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 voltage = detrend(voltage); #+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 velocity = voltageToVelocityL22(voltage, time, gain); disp = lsim(1/(1+s/(2*pi*0.5)), velocity, time); #+end_src * getGroundVelocity :PROPERTIES: :header-args:matlab+: :tangle getGroundVelocity.m :header-args:matlab+: :comments org :mkdirp yes :header-args:matlab+: :eval no :results none :END: <> This Matlab function is accessible [[file:getGroundVelocity.m][here]]. #+begin_src matlab function [time, velocity] = getGroundVelocity() % getGroundVelocity - % % Syntax: [time, velocity] = voltageToVelocityL22() % % Inputs: % - - % % Outputs: % - time - in [s] % - velocity - in [m/s] current_dir = pwd; src_dir = mfilename('fullpath'); src_dir = strsplit(src_dir, '/'); src_dir = strjoin(src_dir(1:end-1), '/'); cd(src_dir); data = load('mat/data_028.mat', 'data'); data = data.data; time = data(:, 3); [velocity] = voltageToVelocityL22(data(:, 1), time, 60); cd(current_dir); end #+end_src * getGroundDisplacement :PROPERTIES: :header-args:matlab+: :tangle getGroundDisplacement.m :header-args:matlab+: :comments org :mkdirp yes :header-args:matlab+: :eval no :results none :END: <> This Matlab function is accessible [[file:getGroundDisplacement.m][here]]. #+begin_src matlab function [time, displacement] = getGroundDisplacement() % getGroundDisplacement - % % Syntax: [time, displacement] = voltageToVelocityL22() % % Inputs: % - - % % Outputs: % - time - in [s] % - displacement - in [m] s = zpk('s'); [time, velocity] = getGroundVelocity(); displacement = lsim(1/s, velocity, time); end #+end_src * getPSDGroundVelocity :PROPERTIES: :header-args:matlab+: :tangle getPSDGroundVelocity.m :header-args:matlab+: :comments org :mkdirp yes :header-args:matlab+: :eval no :results none :END: <> This Matlab function is accessible [[file:getPSDGroundVelocity.m][here]]. #+begin_src matlab function [pxx, f] = getPSDGroundVelocity() % getPSDGroundVelocity - % % Syntax: [pxx, f] = voltageToVelocityL22(in_data) % % Outputs: % - psd - % - f - [time, velocity] = getGroundVelocity(); dt = time(2) - time(1); Fs = 1/dt; win = hanning(ceil(10*Fs)); [pxx, f] = pwelch(velocity, win, [], [], Fs); #+end_src * getPSDGroundDisplacement :PROPERTIES: :header-args:matlab+: :tangle getPSDGroundDisplacement.m :header-args:matlab+: :comments org :mkdirp yes :header-args:matlab+: :eval no :results none :END: <> This Matlab function is accessible [[file:getPSDGroundDisplacement.m][here]]. #+begin_src matlab function [pxx, f] = getPSDGroundDisplacement() % getPSDGroundDisplacement - % % Syntax: [pxx, f] = voltageToVelocityL22(in_data) % % Outputs: % - pxx - % - f - [pxx, f] = getPSDGroundVelocity(); pxx = (sqrt(pxx)./(2*pi*f)).^2; #+end_src