Matlab NSlit

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Matlab Practical

N-Slit Diffraction
Hardik Medhi
227262
MSc - II Physics

1 Code
1 a = input (" Slit Width = ") ;
2 b = input (" Opaque width = ") ;
3 I0 = input (" Incident intensity = ") ;
4 N = input (" Number of slits = ") ;
5 L = 6328 e -4;
6 d = a + b;
7
8 for t = ( - pi /2) :( pi /1000) :( pi /2)
9 x = ( pi * a * sin ( t ) ) / L ;
10 y = ( pi * d * sin ( t ) ) / L ;
11
12 if ( x ==0) && ( y ==0)
13 I = I0 * ( N ^2) ;
14 elseif ( x ==0) && ( y ~=0)
15 I = I0 * sin ( N * y ) ^2/( sin ( y ) ) ^2;
16 elseif ( x ~=0) && ( y ~=0)
17 I = I0 *( sin ( x ) ^2) *( sin ( N * y ) ) ^2/( x ^2 * sin ( y ) ^2) ;
18 end
19 hold on ;
20 plot (t , I , '. ') ;
21 hold off ;
22 end
23 xlabel (" Angle ") ;
24 ylabel (" Intensity ") ;

1
Figure 1: Diffraction pattern for 4 slits

You might also like