% Linmot Shield Test Analysis for By 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 By data

By_bottom_shield = zeros(1, length(z_positions));
sigBy_bottom_shield = zeros(1, length(z_positions));

for i=1:length(z_positions)
   
   Vy1(i) = Load_testplt(i);
   By_bottom_shield(i) = 10*(max(Vy1(i).Vsamp) - min(Vy1(i).Vsamp));  % Units are now Gauss.  1mT = 10 G
end
figure
plot_bars(z_positions, By_bottom_shield, sigBy_bottom_shield, 'bo');
xlabel('Z (mm)');
ylabel('By (G)');
title('FWS By field during upward movement with 15 A motor Power Supply, bottom shield added'); 
saveas(gcf,'By field 15 A with bottom shield.png')


By_integral_15A_bottom_shield = integrate(By_bottom_shield, 2) % G-cm units, step size = 2 cm
