Files
nass-micro-station-measurem…/src/index.org

4.7 KiB

Matlab Function useful for the analysis

voltageToVelocityL22

<<sec:voltageToVelocityL22>>

This Matlab function is accessible here.

  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);
  voltage = detrend(voltage);
  velocity = lsim((S*10^(gain/20))\1, voltage, time);

voltageToDisplacementL22

<<sec:voltageToDisplacementL22>>

This Matlab function is accessible here.

  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');
  velocity = voltageToVelocityL22(voltage, time, gain);

  disp = lsim(1/(1+s/(2*pi*0.5)), velocity, time);

getGroundVelocity

<<sec:getGroundVelocity>>

This Matlab function is accessible here.

  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

getGroundDisplacement

<<sec:getGroundDisplacement>>

This Matlab function is accessible here.

  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

getPSDGroundVelocity

<<sec:getPSDGroundVelocity>>

This Matlab function is accessible here.

  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);

getPSDGroundDisplacement

<<sec:getPSDGroundDisplacement>>

This Matlab function is accessible here.

  function [pxx, f] = getPSDGroundDisplacement()
  % getPSDGroundDisplacement -
  %
  % Syntax: [pxx, f] = voltageToVelocityL22(in_data)
  %
  % Outputs:
  %    - pxx -
  %    - f -

  [pxx, f] = getPSDGroundVelocity();

  pxx = (sqrt(pxx)./(2*pi*f)).^2;