Thursday, August 23, 2012

MATLAB - Single Slit Diffraction


sing_slit_diff
% ************ Single Slit Diffraction ****************
% ***************** By Mahesha MG *********************
clear
clc
thetamax=pi/8;
while(1)
    a=input('Enter slit width (in micro meter): ');
    a=a*1e-6;
    l=input('Enter wavelength (in nm): ');
    l=l*1e-9;
    s=input('Enter slit to screen distance (in m): ');
    theta=-thetamax:1e-3:thetamax;
    y=s*tan(theta);
    alpha=pi*a*sin(theta)/l;
    x=(sin(alpha)./alpha).^2;
    plot(y,x);
    title('Single 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
Enter slit width (in micro meter): 12.6
Enter wavelength (in nm): 480
Enter slit to screen distance (in m): 3.48
Press 1 to continue and 0 to exit: 1
Enter slit width (in micro meter): 12.6
Enter wavelength (in nm): 546
Enter slit to screen distance (in m): 3.48
Press 1 to continue and 0 to exit: 1
Enter slit width (in micro meter): 12.6
Enter wavelength (in nm): 630
Enter slit to screen distance (in m): 3.48
Press 1 to continue and 0 to exit: 0
OUTPUT

No comments:

Post a Comment