# MATLAB code document

```%% Constant V
Vconst=360;
I=[1.22 1.27 1.32 1.37 1.42 1.47 1.52 1.57 1.62 1.72];

VR1=[3.4 5.2 3.8 5.2]*10^-2;
VR2=[3.5 5.2 3.5 5.3]*10^-2;
VR3=[3.4 5.1 3.6 5.0]*10^-2;
VR4=[3.4 5.0 3.4 4.8]*10^-2;
VR5=[3.0 4.7 3.3 4.7]*10^-2;
VR6=[3.2 4.8 3.5 4.5]*10^-2;
VR7=[2.9 4.5 3.5 4.4]*10^-2;
VR8=[3.0 4.3 3.3 4.4]*10^-2;
VR9=[2.9 3.9 3.0 4.0]*10^-2;
VR10=[2.4 3.5 3.0 3.7]*10^-2;
VRavg=zeros(1,10)
for k=1:10
stringy=sprintf('mean(VR%d)',k)
VRavg(k)=eval(stringy)
end

VRerrors=zeros(1,10);
for k=1:10
stringy=sprintf('sqrt((sum((VR%d-mean(VR%d)).^2))/3)',k,k)
VRerrors(k)=eval(stringy)
end
VRerror=mean(VRerrors)

%least squares fit:
VRawfit=polyfit(I,VRavg,1);
VRawval=polyval(VRawfit,I);

%plots
figure(1)
hold on
plot(I,VRawval,'k')
errorbar(I,VRavg,VRerrors,'*');
title('R vs. I at V=360V')
hold off
saveas(figure(1),'ConstantV_rawdata.jpg')

%e/m ratio from slope
Vleft=((7.8E-4)*(VRavg)).^2/(2*Vconst);
Vright=I.^-2;
Verrs=((7.8E-4)*(VRerrors)).^2/(Vconst);
Verr=((7.8E-4)*(VRerror))^2/(Vconst);
Vfit=polyfit(Vright,Vleft,1);
Vval=polyval(Vfit,Vright);
figure(2)
hold on
plot(Vright,Vval)
errorbar(Vright,Vleft,Verrs,'r*');
xlabel(' I^-2, (Amps^-2)');ylabel('(7.8E-4*R)^2/2V (T*m^2/A*V)');
title('m/e slope at V=360V')
hold off
saveas(figure(2),'ConstantV.jpg')

Veoverm=Vfit(1)^-1
Veovermerr=Veoverm/1.756E11-1

%% Constant I
Iconst=1.35;
V=[441.2 430.5 420.5 409 399.9 390.1 380.0 369.8 360.0 350.0];

IR1=[4.0 6.0 4.0 5.5]*10^-2;
IR2=[4.0 5.5 4.0 4.5]*10^-2;
IR3=[3.9 5.4 3.9 5.3]*10^-2;
IR4=[3.9 5.3 3.8 5.3]*10^-2;
IR5=[3.8 5.2 3.8 5.1]*10^-2;
IR6=[3.7 5.1 3.7 5.0]*10^-2;
IR7=[3.5 5.0 3.6 4.8]*10^-2;
IR8=[3.4 4.9 3.5 4.8]*10^-2;
IR9=[3.3 4.8 3.5 4.8]*10^-2;
IR10=[3.3 4.8 3.4 4.5]*10^-2;
IRavg=zeros(1,10)
for k=1:10
stringy=sprintf('mean(IR%d)',k)
IRavg(k)=eval(stringy)
end

IRerrors=zeros(1,10);
for k=1:10
stringy=sprintf('sqrt((sum((IR%d-mean(IR%d)).^2))/3)',k,k)
IRerrors(k)=eval(stringy)
end
IRerror=mean(IRerrors)

%least squares fit:
IRawfit=polyfit(V,IRavg,1);
IRawval=polyval(IRawfit,V);

%plots
figure(3)
hold on
plot(V,IRawval,'k')
errorbar(V,IRavg,IRerrors,'*');
title('R vs. V at I=1.35A')
hold off
saveas(figure(3),'ConstantI_rawdata.jpg')

%e/m ratio from slope
Ileft=((1.053E-3)*(IRavg)).^2/2;
Iright=V;
Ierrs=((1.053E-3)*(IRerrors)).^2;
Ierr=((1.053E-3)*(IRerror))^2;
Ifit=polyfit(Iright,Ileft,1);
Ival=polyval(Ifit,Iright);
figure(4)
hold on
plot(Iright,Ival)
errorbar(Iright,Ileft,Ierrs,'r*');
xlabel(' V, (V)');ylabel('(1.053E-3*R)^2 (T*m^2)');
title('m/e slope at I=1.35A')
hold off
saveas(figure(4),'ConstantI.jpg')

Ieoverm=Ifit(1)^-1
Ieovermerr=Ieoverm/1.756E11-1

%FINAL RESULT
eoverm=(Veoverm+Ieoverm)/2
VIeovermerr=eoverm/1.756E11-1
```