Physics307L F08:People/Osinski/Lightspeed/Lightspeed.m
From OpenWetWare
Jump to navigationJump to search
%% 1st Calibration delay1=[0 .5 1 2 4 6 8 10]; voltage1=[5.64 5.76 5.88 6.16 6.60 6.84 7.12 7.32]; figure(1) subplot(2,2,1) plot(delay1,voltage1),title('1st Calibration'),xlabel('delay (ns)'),ylabel('voltage (V)') % the actual signal produced by a delay is given by the value subtracted % from the 0 delay value. realvolt1=voltage1-voltage1(1); % I ignore the first 3 elements of my voltage data vector in order to determine % the proportionality factor between 2ns and the time difference. Calib1=[realvolt1(4),realvolt1(5)-realvolt1(4),realvolt1(6)-realvolt1(5),... realvolt1(7)-realvolt1(6),realvolt1(8)-realvolt1(7)]; stdCalib1=std(Calib1) % Now I find the mean of these values so that I get one number as the % proportionality factor. Calib1=mean(Calib1); % I repeat the same procedure for Calibration 2 and then find their average %% 2nd Calibration delay2=[0 .5 1 2 4 6 8 10]; voltage2=[5.00 5.12 5.24 5.44 5.88 6.28 6.64 6.88]; subplot(2,2,2) plot(delay2,voltage2),title('2nd Calibration'),xlabel('delay (ns)'),ylabel('voltage (V)') realvolt2=voltage2-voltage2(1); Calib2=[realvolt2(4),realvolt2(5)-realvolt2(4),realvolt2(6)-realvolt2(5),... realvolt2(7)-realvolt2(6),realvolt2(8)-realvolt2(7)]; stdCalib2=std(Calib2); STDCALIB=(stdCalib2+stdCalib1)/2 Calib2=mean(Calib2); CALIB=(Calib1+Calib2)/2 %this tells me how to read time from the voltage signal on the scope %% 1st Data Set D1=0:10:150; V1=[5.80 5.72 5.64 5.52 5.44 5.40 5.36 5.28 5.28 5.12 4.96 4.96 4.96 4.88 4.64 4.64]; subplot(2,2,3) plot(D1,V1),title('1st Raw Data Set'),xlabel('distance (cm)'),ylabel('voltage (V)') %% 2nd Data set D2=0:10:150; D2(2)=11; V2=[5.76 5.68 5.56 5.56 5.52 5.36 5.32 5.28 5.16 5.08 5.00 4.92 4.92 4.80 4.88 4.76]; subplot(2,2,4) plot(D2,V2),title('2nd Raw Data Set'),xlabel('distance (cm)'),ylabel('voltage (V)') %% Averaging Data AVG=(V1+V2)./2; figure(2) plot(D1,AVG),title('averaged data'),xlabel('distance (cm)'),ylabel('voltage (V)') %% Translation from voltage to time to speed % Both data sets span a distance of 1.5m. I find the total change in % voltage from begining to end for both sets and then average this % quantity. deltaV1=V1(1)-V1(end) deltaV2=V2(1)-V2(end) DELTAV=(deltaV1+deltaV2)/2 % In order to convert DELTAV from voltage to time I use the % proportionality factor, CALIB/2, calculated above (divided by 2 so that I get my answer in terms of ns). TIME=(2*DELTAV)/CALIB DISTANCE=1.5 LIGHTSPEED=DISTANCE/TIME % My result is in m/ns so I make sure to do the proper conversiion later. %% Standard Deviation of the Mean % Using the mean value of data calculated I above I subract each data set % from the mean to obtain the deviation of each data point from the mean. % Then I find the mean of the squared deviations (variance). Since each % data point has really only been taken twice the standard deviation is % going to be the same as the std of the mean since dividing by sqrt(N-1) % does not make any difference when N is only 2. Mean1=AVG-V1; Mean2=AVG-V2; Var1=(sum(Mean1.^2))/length(Mean1); Var2=(sum(Mean2.^2))/length(Mean2); STDmean1=sqrt(Var1); STDmean2=sqrt(Var2); STDMEAN=(STDmean1+STDmean2)/2