Wednesday, August 22, 2012

MATLAB - Double Slit Interference


interference
% *********** Interference (Double slit) **************
% ***************** By Mahesha MG *********************
clear
clc
thetamax=0;
while(1)
    d=input('Enter slit seperation (in meter): ');
    l=input('Enter wavelength in nm: ');
    l=l*1e-9;
    s=input('Enter source to screen distance in m: ');
    ymax=10*l*s/d;
    if thetamax==0
    thetamax=atan(ymax/s);
    theta=-thetamax:1e-5:thetamax;
    y=s*tan(theta);
    end
    x=4*cos(pi*d*sin(theta)/l);
    plot(y,x);
    hold all;
    ch= input('Press 1 to continue and 0 to exit: ');
if ch == 0
    break;
end
end
Enter slit seperation (in meter): 0.00012
Enter wavelength in nm: 480
Enter source to screen distance in m: 0.55
Press 1 to continue and 0 to exit: 1
Enter slit seperation (in meter): 0.00012
Enter wavelength in nm: 546
Enter source to screen distance in m: 0.55
Press 1 to continue and 0 to exit: 1
Enter slit seperation (in meter): 0.00012
Enter wavelength in nm: 630
Enter source to screen distance in m: 0.55
Press 1 to continue and 0 to exit: 0
OUTPUT

No comments:

Post a Comment