Add folder for Matlab functions

This commit is contained in:
Thomas Dehaeze 2019-05-14 16:58:45 +02:00
parent 0ead56a3a1
commit 627859f026
3 changed files with 119 additions and 0 deletions

78
src/index.org Normal file
View File

@ -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:
<<sec:voltageToVelocityL22>>
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:
<<sec:voltageToDisplacementL22>>
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

View File

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

View File

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