Finding chi-squared value to fraunhoffer diffraction data

1 view (last 30 days)
This is my first time posting, I'm essentially a novice when it comes to matlab so please be patient. I've run into a problem with trying to get a goodness of fit parameter for my double slit diffraction data. The observed data is the number of counts from a PMT spanning the diffraction pattern. This data had a dark count subtracted, and then normalized. The theoretical model is plotted alongside the observed data. I want to include a goodness of fit, however, I am at a loss of how to proceed using poisson statistics (I think since it is a random number of independent events) to get the variance, and then chi-squared. Below is the the code that I wrote, as well as a plot of the data.
clear
clc
displacement = -0.0022:0.0001:0.0022;
intensity = [2914 3501 3587 3196 2370 2275 3630 5510 7405 8956 5022 2944 2860 5550 9119 11163 9067 6255 2792 2904 6560 9558 11190 9406 5590 3112 3607 7496 11230 11989 9785 5368 3122 3684 6456 7884 7759 5837 3826 2795 3255 3440 3808 3216 2980];
darkintensity = intensity-1170;
e = sqrt(darkintensity)./10819;
data = darkintensity./10819;
thetamax=pi/500;
while(1)
a=input('Enter slit width (in micro meter): ');
a=a*1e-6;
d=input('Enter slit seperation (in mm): ');
d=d*1e-3;
l=input('Enter wavelength (in nm): ');
l=l*1e-9;
s=input('Enter slit to screen distance (in m): ');
theta=-thetamax:.00001:thetamax;
y=s*tan(theta);
alpha=pi*a*sin(theta)/l;
beta=pi*d*sin(theta)/l;
x1=cos(beta).^2; % Interference term
x2=(sin(alpha)./alpha).^2; % Diffraction term
x=x1.*x2; % Combined effect
hold on
plot(y,x,'--b',y,x2,':r');
errorbar(displacement,data,e,'g');
hold off
title('Double slit diffraction Mahesha MG 2012');
xlabel('Distance in m');
ylabel('Intensity');
hold all;
ch= input('Press 1 to continue and 0 to exit: ');
if ch == 0
break;
end
end
slit width = 85
slit separation = 0.406
wavelength = 546
screen distance = 0.5

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!