%% Electron Diffraction close all; clear all; clc %constants L=.130; m=9.11*10^-31; e=1.6*10^-19; h=6.626*10^-34; %Gathered Data: V=[(4900:-100:3600),3400,3200]; %OD=[38.62324,39.76624,40.3098,40.89400,41.66794,... % 41.66794,42.38752,43.7388,43.36288,45.31106,... % 45.62094,45.6438,47.7393,48.38700,50.01006,... % 52.83454]; OD=[36.99,37.11,37.31,37.63,38.02,38.28,38.64,39.06,... 39.45,39.86,40.15,40.55,40.92,41.19,41.87,42.23] dOD=[1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,... 1.7,1.7,1.7,1.7,1.7];%this is error in OD OD=OD*10^-3; dOD=dOD*10^-3; ID=[20.35,20.35,21.74,22.04,22.50,22.86,22.24,22.97,23.03,... 23.23,23.55,23.74,24.17,24.41,24.78,25.04]; %ID=[24.1555,24.38400,24.4792,24.58212,25.1206,... % 25.89022,28.70200,28.88234,29.45384,29.7307,... % 30.1498,30.23616,31.0515,31.87700,32.2072,... % 32.4739]; this is the first and unsuccesful run dID=[1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,... 1.7,1.7,1.7,1.7,1.7]; ID=ID*10^-3; dID=dID*10^-3; %% optical corrections for length R=66*10^-3; DL1=R*(1-cos(asin(OD/(2*R))));%correction for length DT1=1.5*10^-3*sin(atan(OD/(2*(L+DL1))));%correction for thickness DL2=R*(1-cos(asin(ID/(2*R)))); DT2=1.5*10^-3*sin(atan(ID/(2*(L+DL2)))); L1=L-DT1-DL1; L2=L-DT2-DL2; %% outer diameter lsr fit clc figure ODactual=.123; %least squares fit lsrvec=min(1./sqrt(V)):10e-6:max(1./sqrt(V)); p = polyfit(1./sqrt(V),OD,1); p(1)=2.510;p(2)=0; lsr=polyval(p,lsrvec); plot(1./sqrt(V),OD,'x',lsrvec,lsr); hold on; errorbar(1./sqrt(V),OD,dOD,'x');hold off xlabel('1/sqrt(V)');ylabel('Outer Diameter') set(gcf,'color',[1,1,1]) legend('Data','Least Squares Line'); OuterSlope=p(1); odcalc=2.*mean(L1).*h/(sqrt(2*m*e)*OuterSlope*10^-9)%decided to use the mean Error=100*(ODactual-odcalc)/ODactual %% inner diameter lsr fit figure IDactual=.213; %least squares fit lsrvec=min(1./sqrt(V)):10e-6:max(1./sqrt(V)); p = polyfit(1./sqrt(V),ID,1); p(1)=1.465;p(2)=0; lsr=polyval(p,lsrvec); plot(1./sqrt(V),ID,'x',lsrvec,lsr);set(gcf,'color',[1,1,1]); hold on; errorbar(1./sqrt(V),ID,dID,'x'); hold off xlabel('1/sqrt(V)');ylabel('Outer Diameter') legend('Data','Least Squares Line'); InnerSlope=p(1); idcalc=2*mean(L2)*h/(sqrt(2*m*e)*InnerSlope)/10^-9 Error=100*(IDactual-idcalc)/IDactual %% All data plot close all ActualVec=linspace(min(V),max(V),100); %One spacing D1=2*h*L2./(ID.*sqrt(2*m*e).*sqrt(V)*10^-9) IDErrBars=D1.*dID./ID; figure plot(V,D1,'x',ActualVec,IDactual*ones(size(ActualVec)));set(gcf,'color',[1,1,1]); hold on errorbar(V,D1,IDErrBars,'x') xlabel('Voltage (V)');ylabel('Lattice Spacing(nm)'); %ploting mean and sem plot(V,mean(D1)*ones(size(V)),'r') plot(V,(mean(D1)+std(D1)./sqrt(length(D1))).*ones(size(V)),'g',... V,(mean(D1)-std(D1)./sqrt(length(D1))).*ones(size(V)),'g') hold off legend('measured','actual','ebars','mean','sem') %means %PError1=100*(IDactual-mean(D1))/IDactual %Second Spacing D2=2*h*L1./(OD.*sqrt(2*m*e).*sqrt(V)*10^-9); ODErrBars=D2.*dOD./OD; figure plot(V,D2,'x',ActualVec,ODactual*ones(size(ActualVec)));set(gcf,'color',[1,1,1]) hold on errorbar(V,D2,ODErrBars,'x') xlabel('Voltage (V)');ylabel('Lattice Spacing(nm)'); %ploting mean and sem plot(V,mean(D2)*ones(size(V)),'r') plot(V,(mean(D2)+std(D2)./sqrt(length(D2))).*ones(size(V)),'g',... V,(mean(D2)-std(D2)./sqrt(length(D2))).*ones(size(V)),'g') hold off legend('measured','actual','ebars','mean','sem') %means %% Means and SEMS MeanD1=mean(D1) MeanD2=mean(D2) Sem1=std(D1)/sqrt(length(D1)) Sem2=std(D2)/sqrt(length(D2)) PError1=100*(IDactual-mean(D1))/IDactual PError2=100*(ODactual-mean(D2))/ODactual