% Linmot Shield Test Analysis for Bx 15 A motor setup.
%  Finds the max and min of the voltage sample data and then computes the
%  field change for each z point.  Calibration is 1V = 1mT
 
z_positions = -140:20:140;

% Get Bx data

Bx_bottom_shield = zeros(1, length(z_positions));
sigBx_bottom_shield_run_2 = zeros(1, length(z_positions));

for i=1:length(z_positions)
   
   Vx1_run_2 = Load_testplt(i);
   Bx_bottom_shield(i) = 10*(max(Vx1_run_2.Vsamp) - min(Vx1_run_2.Vsamp));  % Units are Gauss.  3mT = 3V, so 1mT/V = 10 G/V
end
figure
plot_bars(z_positions, Bx_bottom_shield, sigBx_bottom_shield_run_2, 'bo');
xlabel('Z (mm)');
ylabel('Bx (G)');
title('Linmot Bx field during upward movement with 15 A motor Power Supply');

Bx_integral_15A_bottom_shield_run_2 = integrate(Bx_bottom_shield, 2) % G-cm units when dx is 2 cm

% Get Bx background too

 Vx_background = importdata('background z = 0.ru1', ' ', 2);
  Bx_background = 10*(max(Vx_background.data(:,3)) - min(Vx_background.data(:,3))) % Units are Gauss.  3mT = 3V, so 1mT/V = 10 G/V
  