User:Darrell Bonn/Notebook/307L Lab book/lab 6 Balmer/balmerlab1.m

From OpenWetWare

Jump to: navigation, search
%Using the values taken in runs 1 - 4
% Not using runs 5 & 6 for this as that was taken to show
% variablilty of data with single calibration and weights data unfairly
% towards last calibration

V1Raw = [410.8 410 412 410]; %Violet 1 data
V2Raw = [435.5 434 436 434]; %Violet 2 data
GBRaw = [488.8 486 489 486]; %Green Blue data
RRaw = [666 657 666 656];    %Red data

V1 = mean(V1Raw); V1var = var(V1Raw);
V2 = mean(V2Raw); V2var = var(V2Raw);
GB = mean(GBRaw); GBvar = var(GBRaw);
R = mean(RRaw);   Rvar = var(RRaw);

for n=3:10
    %Candidates for R from Violet 1 data
    RV1(n) = V1 * (1/4 - 1/n.^2);
    RV1(n) = 1/RV1(n);
    
    %Candidates for R from Violet 2 data
    RV2(n) = V2 * (1/4 - 1/n.^2);
    RV2(n) = 1/RV2(n);

    %Candidates for R from green blue data
    RGB(n) = GB * (1/4 - 1/n.^2);
    RGB(n) = 1/RGB(n);
    
    %Candidates for R from Red data
    RR(n) = R * (1/4 - 1/n.^2);
    RR(n) = 1/RR(n);
end
RV1 = RV1.* 1E9;
RV2 = RV2.* 1E9;
RGB = RGB.* 1E9;
RR = RR.* 1E9;

n = 1:10;
figure(1);
plot(n(3:10), RV1(3:10), 'b'); 
hold on; 
plot(n(3:10), RV2(3:10),'b--'); 
plot(n(3:10), RGB(3:10),'g'); 
plot(n(3:10), RR(3:10),'r');
hold off; grid on;


Rydberg = RR(3) + RGB(4) + RV2(5) + RV1(6); 
Rydberg = Rydberg/4; disp(sprintf('Rydberg: %.4E',Rydberg));
R(n) = Rydberg;

figure(1); hold on; plot(n(3:10), R(3:10), 'k');hold off;
title(sprintf('Averaged Data from Balmer lab: R = %.3E', Rydberg));
legend('Violet 1', 'Violet 2', 'Blue-Green', 'Red', 'Calculated R', -1);
xlabel('Value of n2');
ylabel('Possible Value of R');

%---------------------------------------------------------------------
% Error calculations

disp(sprintf('variance: %.3f, %.3f, %.3f, %.3f', V1var, V2var, GBvar, Rvar))
disp(sprintf('Standard Dev: %.3f, %.3f, %.3f, %.3f', sqrt(V1var), sqrt(V2var), sqrt(GBvar), sqrt(Rvar)))

% V1 = V1 + sqrt(Rvar);
% V2 = V2 + sqrt(Rvar);
% GB = GB + sqrt(Rvar);
% R = R + sqrt(Rvar);

V1 = mean(V1Raw) + sqrt(Rvar);
V2 = mean(V2Raw) + sqrt(Rvar);
GB = mean(GBRaw) + sqrt(Rvar);
R = mean(RRaw) + sqrt(Rvar);

for n=3:10
    %Candidates for R from Violet 1 data
    RV1(n) = V1 * (1/4 - 1/n.^2);
    RV1(n) = 1/RV1(n);
    
    %Candidates for R from Violet 2 data
    RV2(n) = V2 * (1/4 - 1/n.^2);
    RV2(n) = 1/RV2(n);

    %Candidates for R from green blue data
    RGB(n) = GB * (1/4 - 1/n.^2);
    RGB(n) = 1/RGB(n);
    
    %Candidates for R from Red data
    RR(n) = R * (1/4 - 1/n.^2);
    RR(n) = 1/RR(n);
end
RV1 = RV1.* 1E9;
RV2 = RV2.* 1E9;
RGB = RGB.* 1E9;
RR = RR.* 1E9;

n = 1:10;
figure(2);
plot(n(3:10), RV1(3:10), 'b'); 
hold on; 
plot(n(3:10), RV2(3:10),'b--'); 
plot(n(3:10), RGB(3:10),'g'); 
plot(n(3:10), RR(3:10),'r');
hold off; grid on;


RydbergHi = RR(3) + RGB(4) + RV2(5) + RV1(6); 
RydbergHi = RydbergHi/4; disp(sprintf('Rydberg High: %.4E',RydbergHi));
R(n) = RydbergHi;

RydbergDelta = Rydberg - RydbergHi;
RydbergLo = Rydberg + RydbergDelta;
disp(sprintf('Delta: %.4E', RydbergDelta))


figure(2); hold on; plot(n(3:10), R(3:10), 'k');hold off;
title(sprintf('Averaged Data from Balmer lab: R = %.3E', Rydberg));
legend('Violet 1', 'Violet 2', 'Blue-Green', 'Red', 'Calculated R', -1);
xlabel('Value of n2');
ylabel('Possible Value of R');
Personal tools