Friday, August 24, 2012

MATLAB - Double Slit Interference and Diffraction combined


dbl_slit_diff
% ********* Double Slit Interference and Diffraction combined ***********
% ************************** By Mahesha MG ******************************
clear
clc
thetamax=pi/50;
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:1e-5: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
    plot(y,x,'b',y,x2,'--r');
    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
Enter slit width (in micro meter): 30
Enter slit seperation (in mm): 0.15
Enter wavelength (in nm): 557
Enter slit to screen distance (in m): 0.5
Press 1 to continue and 0 to exit: 0
OUTPUT

5 comments:

  1. The equations of term of alpha and beta shoud be divided by wavelength. Please, correct them.

    ReplyDelete
    Replies
    1. alpha=pi*a*sin(theta)/l; here l is wavelength. It is correct.

      Delete
    2. Thank you Mahesha for your contribution. But I have juste a small question:how can I display (visualize) the frange pattern obtained in the focalization plane, which is not flat (like this presented here), but convex?

      Delete
  2. Thank you Mahesha MG. I have a small question: what happen if the screen is not flat(plane) but convex?

    ReplyDelete
  3. what if we need the graph to be plotted on inensity against pixels how should we change the program?

    ReplyDelete