Sie sind auf Seite 1von 16

# EOP Set 1

## ENGINEERING OPTICS, SET 1 INTERFERENCE AND DIFFRACTION

This set of exercises is concerned with the methods of calculating diraction patterns from slits using Huygens Principle. It is assumed that your have some familiarity with MATLAB and can understand how it works with matrices. However it is not assumed that you know the syntax of writing MATLAB statements, and therefore you will be helped to write whatever scripts are necessary. This physics involved in these exercises is covered in Lecture Notes, 1.5.02. This set of exercises should take you two weeks to complete.

PRE-LAB
When light travels past an object or through an opening, it spreads out or diracts. You can calculate the pattern of light intensity this produces by using Huygens Principle. This states that every point on a wavefront can be considered as a source of secondary wavelets which spread out in all directions. To nd the resultant displacement at any point, you combine all the individual displacements produced by these secondary waves, using the superposition principle and taking into account their amplitudes and relative phases. Consider a plane wave impinging on an opaque wall which has a tiny hole in it. The hole acts as a source, S, of spherical waves, which we can detect when they hit a screen some distance away.
wavelength ! r S (0,0) y x wall screen

detector D (x d , yd )

Now imagine that the the electric eld variable close to the point S, which we write Es , is varying sinusoidally with time, with an angular frequency and an amplitude Emax , Es (t) = Emax cos(t). (1.1)

Then the eld at the point D, a distance r away, will also be varying sinusoidally. The intensity of the light at that point falls o as 1/r2 , because it spreads out uniformly in all directions. Therefore its amplitude can be written as A/r, where A is some constant. Its phase will depend on how many wavelengths t into the distance r. In other words, Ed (t) = A cos(t 2r/), r where r = q 2 x2 + yd . d (1.2)

From arguments given in lectures and in the textbook (see: Lecture Notes, 1.3.1) you know that 2 the intensity of the light at D is equal to the time average value of Ed , multiplied by 0 c. In other words Intensity at D = 0 ch Ed (t)2 i = 0 c A2 . 2 r2 (1.3)

EOP Set 1

Note, if you dont know the amplitude of the oscillation, A, you can (in principle) measure the eld at time t = 0 and measure it again a quarter of a period later (t = /4 = /2). Then you know that, A A Ed (0) = cos(2r/) = cos(2r/) (1.4) r r A A Ed ( /4) = cos(/2 2r/) = sin(2r/) (1.5) r r So if you square and add the two measurements, the uctuations due to the sinusoidal variation disappear (because sin2 + cos2 = 1), and the intensity at D will be given by Intensity = 0 c Ed (0)2 + Ed ( /4)2 . 2 (1.6)

Now consider that the source consists of a number, M , of similar point sources.
wavelength !

detector D (x d , yd )

## slit width a y x wall screen

If the sources are located at points (xsj , ysj ), each with the same initial amplitude (A), the total eld at the point D, Etot , is given by Etot (0) =
M XA cos(2rj /) r j=1 j

and

Etot ( /4) =

M XA sin(2rj /) r j=1 j

(1.7)

where: rj =

And the total intensity is got by squaring and adding, 0 c Itot (xd , yd ) = Etot (0)2 + Etot ( /4)2 . 2

## q (xd xsj )2 + (yd ysj )2 .

(1.8)

(1.9)

It would simplify the artithmetic if we could forget about the constant quantity 0 c. In all the computations we will do, the amplitude of the wave at the source is arbitrary. We will never calculate absolute values of intensity. So we are at liberty to choose the way intensity is measured so that this constant is eectively equal to 1. In such a measurement system, Itot (xd , yd ) = 1 Etot (0)2 + Etot ( /4)2 . (1.10) 2 Note, we keep the factor 1 because it has a relevant meaning. It states that the intensity is related 2 to the time average of the amplitude squared. (See Lecture Notes, Eqn 1.3 F.) As you will see, the intensity pattern produced by light coming through an opening (or openings) is quite complicated in the immediate vicinity of the opening (the Fresnel regime) but much simpler if you go far away (the Fraunhofer regime). In these exercises you will investigate where the transition between these two regimes is located, and how its location depends on the size of the opening and on the wavelength of the light.

EOP Set 1

IN LAB
EOP1.1 Visualization of wave elds We start o by investigating how the eld from a point source varies as we move the detector to all points throughout the space between the wall and the screen. This involves writing a short script to calculate the eld E at the points D, due to a single point source at S, using equation 1.2.

wavelength

detector D (x d , yd )

S (0,0)

wall

scrnDist

screen

This script can be found on the web site for this module as an m-le called op1ex1.m. Download this le to your home directory and open it. Note what MATLAB statements have already been entered into it. You can run this script at any time, simply by typing its name in the command window. >> op1ex1; (You dont type the >> of course. That is the MATLAB prompt. And dont forget MATLAB is case sensitive.) (a) Firstly we must choose the variables to work with, and set them to appropriate values. For this exercise we will use the following (all lengths are expressed in metres): wavelength: distance to the screen: width of the screen: x-coord of the source: y-coord of the source: amplitude of the source: lambda scrnDist scrnWdth xs ys A = = = = = = 4.0e-3 5.0e-2 2.4e-2 0 0 1 (4.0 mm) (50 mm) (12 mm)

(arbitrary)

Notice that we have chosen an unusually large value for the wavelength. In the succeeding exercises we will be dealing with waves in the optical range, that is, wavelengths between 400800 nm. However right now we want to see the oscillatory behaviour of the waves, and so we will pretend we are doing these experiments with microwaves. Open the script and observe the MATLAB statements which correspond to these assignments. If you dont know already, ask your tutor about the meaning of the symbols ; and %. Run the script. Now check that these values are assigned properly. To do this, type in the command window, the name of one of the variables, press the enter key and MATLAB will reply with its value. For example, >> lambda (b) We want to calculate E throughout the space between the source and the screen. In the script we have chosen a rectangular array of detection points whose x-coordinates vary between close to 0 and scrnDst and whose y-coordinates vary between -scrnWdth/2 and +scrnWdth/2. Lets not make the number N of these points too big to start with. Five should be plenty. Identify in the script the six lines of MATLAB commands which calculate the coordinates of these points. Again, if you dont know already, ask about the meaning of [], : and .

EOP Set 1 The MATLAB function meshgrid is what actually constructs the array of detection points. It generates the variables xd and yd as a 6 5 matrix. Examine these matrices by typing their names in the command window. Make sure you can identify which elements of the matrices correspond to which positions in the diagram at the top of page 7. Note in the script the two lines of code which calculate the eld variable E(0). As usual, if you dont know already, ask about the meaning of the . before the ^ and the /. It should be clear what is the relationship between these commands and the basic equation we are working with, Eq.( 1.2). Check that the script has calculated one value of E0 for each of the 6 5 detection points, and that those values look reasonable the eld should be large near the source and decrease further away from it. Change the size of the array of detection points, by setting the variable N equal to 500 rather than 5. You will need to make the change inside the script, and save it into the working directory, as op1ex1d. Then run the script (by typing its name in the command window). Investigate the values of the eld variable E between the source and the screen by plotting it as a 3-D plot xd and yd along the x- and y-axes, and E0 along the z-axis. You do this by typing this statement, which is one of the standard MATLAB functions, in the command window: >> mesh(xd,yd,E0); Check that you understand what the plot is telling you. Change the value of wavelength inside the script to 8 mm and then to 2 mm. Save each time, run and re-plot. Are the changes in the gure as you expected? Another useful way to represent the eld is to do a pseudo-colour contour plot. Close the mesh plot and type this statement in the command window: >> PseudoColor(xd,yd,E0); This is not a standard MATLAB function. Download it from the course web site. Check that you understand all the information in the plot. Try three dierent wavelengths, 8 mm, 4 mm and 2 mm. Save each time, run and re-plot. Is everything still as you expected? In many optics textbooks, the way harmonic waves radiate out from a point source is usually represented by a diagram like this (see for example Lecture Notes, Fig 28). Make sure that you are happy with the correspondence between the two diagrams. In particular you should be clear that both diagrams represent a picture taken at some particular instant in time, and we have to imagine that the circles on this diagram and the contour plot move outwards as time goes on. If these two diagrams do indeed convey the same information, what features on your contour plot do the circles on the conventional diagram correspond to?

(c)

(d)

(e)

(f)

Tutors initials

## EOP Set 1 EOP1.2 Point source interference

The next exercise is to calculate the eld due to two point sources separated by a small distance. As you know, this is a situation which gives rise to interference.

## wavelength S (0,+) S (0,)

detector D (x d , yd )

2 = source separation

screen

You need to extend the script used in problem 1, to get it to handle two sources instead of one. So, before you start, open that script and save it in the current directory under the name op1ex2.m. (Use Save as.) You now have a second copy in which can now make changes. (a) Firstly you need to add another parameter to the ones that are set at the top of your scriptthe separation between the two sources. separation of sources: srceSepn = 1.2e-2; (1.2 cm)

Write the appropriate statement into the script directly under the other assignments. Remember that MATLAB is case sensitive when it comes to names of variables. (b) There are two sources now, so we will make the x- and y-coordinates of the source a (1 2) row vector. The appropriate statements are: xs = [0 , 0]; ys = [-srceSepn/2 , srceSepn/2]; Replace the statements that originally set xs and ys to zero with these two statements. (c) Since there are now two sources, we must calculate two arrays of values of r between each source and all the detector points. You do this by replacing the single statement that calculated r previously with these two statements, r1 = sqrt((xd-xs(1)).^2 + (yd-ys(1)).^2); r2 = sqrt((xd-xs(2)).^2 + (yd-ys(2)).^2); Then the eld variable at t = 0, at any of the detector points is the sum of two terms, E0 = A*cos(2*pi*r1/lambda)./r1 + A*cos(2*pi*r2/lambda)./r2; Make these changes in the script, save and run it, just to check that you havent made any silly mistakes. (d) Examine the results of the calculation by again plotting E(0) as a 3-D plot (mesh) and as a contour plot (PseudoColor). Describe briey in this box the main characteristics of the pattern you observe when you do a contour plot.

Again, in many introductory optics textbooks, interference from a double slit is explained with the aid of a diagram like the following (see for example (See Lecture Notes, g 30.)).

10

EOP Set 1

S1

S2

Convince yourself that your contour plot is essentially the same as this diagram. (e) Now change the wavelength. Try three dierent wavelengths: 8 mm, 4 mm and 2 mm. Plot the results as a contour plot and describe in this box how the contour plot changes as the wavelength increases.

(f) Set the wavelength back tp 4 mm and change the separation between the two sources to 24 mm. Describe in this box how the contour plot changes as the source separation increases.

Tutors initials

NOTES.

## EOP Set 1 EOP1.3 Interference of two point sources

11

This next exercise involves investigating the interference eects we have been observing by measuring the intensity of the wave eld at points along the screen. That means that we consider that there is a row of detectors attached to the screen as in the diagram on page 5, rather than a rectangular array of detectors lling the area between sources and screen. Then these measurements can be plotted as a 1-dimensional graph of intensity against the y-coordinates of the detectors. (a) Firstly we need to calculate the intensity using equation 1.10. This involves calculating the wave eld at time t = /4 as in equation 1.7. Let us denote this quantity by E4. So you need to add these two statements to the end of the script. E4 = A*sin(2*pi*r1/lambda)./r1 + A*sin(2*pi*r2/lambda)./r2; Itot = (E0.^2 + E4.^2)/2; Make these changes and save the new script as op1ex3.m. However, if you try to observe Itot by plotting it using mesh or PseudoColor you wont be able to detect much useful information. The relative intensities are too small to register clearly on the graph. (b) Run the script with these new parameters (optical wavelengths now!), wavelength = 600 nm screen width = 30 mm screen distance = 50 mm source separation = 0.016 mm

This time we plot the intensity only at points on the screen. The coordinates of the detector points on the screen are [xd(:,N),yd(:,N)], and the eld intensities at those points are Itot(:,N). Remember, if you dont know what :,N means, ask. And to plot these values of Itot against y on the screen you type, in the command window: >> plot(yd(:,N),Itot(:,N)); (You might like to add this statement to the end of your script to save typing it over and over.) Draw in the box below the pattern you see on the computer.

(c) Before investigating this pattern, save a copy of it for future reference. You will need it for Exercise OP2.1(d). This is what you do to save a gure. Make sure the gure is active by clicking inside it. Choose Save as from the File menu. Instruct it to be saved as a MATLAB gure, and give it the name op1fig1.fig. When you want to recall it, you simply choose Open from the File menu and select it by name, as usual. It would be sensible to do that immediately to make sure it was saved correctly. (d) We are now at the point where the physics of what is happening becomes important. Answer the following questions about this pattern. Why is the total intensity zero at some points along the screen?

12

EOP Set 1 Do the heights of the maximums change as you go away from the centre? Why?

How does the pattern change if you increase the wavelength of the light? Why?

(e) The theory of two-slit diraction predicts that the maximums and minimums of these interference fringes should be arranged along the y-axis at distances from the centre of the screen given by, ym = m scrnDist srceSepn or ym = (m + 1 ) 2 scrnDist srceSepn (1.11)

for a maximum (bright fringe) or a minimum (dark fringe) respectively, where m is an integer. (See Lecture Notes, Eq.15 B.) Measure the positions of several of these fringes, both bright and dark. Make sure your detector points along the screen are close enough together N should be 1000. Note: you may need to use ginput to measure these positions accurately. Calculate the equivalent value of m for each (using 1.11) and enter them in these boxes. You should be able to achieve no more than 2 signicant gures. Right?
bright fringes dark fringes

m: Are these numbers sgnicantly dierent from integers? (f) Lastly, there is another way of representing the intensity at points along the screen, and that is by using a grey scale representation. Download from the modules web site the le which does this, and open it by typing in the command window, GrayScale(yd(:,N),Itot(:,N)); This way of representing the data assumes that the sources in the gures on pages 5 and 17 are not small round holes, but long narrow slits, parallel to the z-direction, perpendicular to the plane of the paper. This mimics what you normally nd in an experimental laboratory. What you have just drawn on the computer face is very similar to what you would actually see on a physical screen in the laboratory a series of bright fringes, each one being parallel to the z-axis. Conrm that this is what you see.

Tutors initials

NOTES.

## EOP Set 1 EOP1.4 Slit of nite width

13

The next exercise is to calculate the intensity due to a slit of nite width (by which we mean that the width is normally small but non-zero). As you know, this is a situation which gives rise to diraction of a dierent character.
wavelength !

detector D (x d , yd )

## slit width a y x wall screen

The computing task is quite straightforward. The slit through which light passes can be considered as equivalent to a row of point sources. The light reaching the screen from the slit is therefore the superposition of the light coming from all of the individual equivalent point sources. In problems OP1.2/3 we calculated the superposition of light from two sources. What we will work with from now on is essentially an extension of that script, but with some important structural changes. You will nd it in the COSC web site under the new name HuygensConstruction.m. Download it and become familiar with what it does, as follows. (a) The rst thing we did to the script was to make it self-contained, so that you dont have to make internal alterations every time you need to change the value of a variable. To do this we assign values to all the variables outside the m-le. We make them global variables. From now on we want to investigate how light diracts, which means we have to work with wavelengths in the range 400800 nm. In order to keep the diraction patterns looking much the same as before we will also need to make the width of the slit correspondingly smaller of the order of 102 mm. So enter these statements into the command window (remember all lengths are in metres): >> global lambda scrnDist scrnWdth slitWdth; >> lambda = 600e-9; >> scrnDist = 50e-3; >> scrnWdth = 30e-3; >> slitWdth = 4.0e-6; (Dont worry if you get any error messages. They should be self explanatory.) Look in the m-le, and youll see the global statement repeated there. So these values are now accessible to the script without having to be set each time it is run. You will also notice that the numbers of sources and detectors have been set to 7 and 5 respectively. This is for present convenience. Well increase them later. (b) The other big structural change can be seen in the rst and last lines. The script has been turned into a MATLAB function. When you want to do the calculations it contains you call it like this. Caution: the global variables must still be set. >> [yd Itot] = HuygensConstruction; Do this (without the nal ;), and MATLAB will print out two (5 1) column vectors for yd and Itot. You can plot them if you like. A call like this can be made from inside another script, and the return at the end of the le tells MATLAB to go back and execute the next statement after the point at which the function was called. If you dont understand, ask.

14

EOP Set 1 (c) Look at the rest of the le, and see how the calculation is done. The coordinates of the sources, xs and ys, are calculated as they were before, except that now they are row vectors and not just pairs of numbers. Likewise the coordinates of the detectors, xd and yd, are calculated similarly, as column vectors. The next step is the tricky one. There are M sources and N detectors, therefore there are M N dierent distances between any one of the sources and any one of the detectors. The program calculates all of these in one M N matrix. To do this the program replaces each of xd-xs and yd-ys with matrices of the same size, the sources with all their columns the same and the detectors with all their rows the same. (d) Once the M N dierences have been calculated, it is trivial to work out the M N values of rj (see Eq.(1.8)). Then the program sums over the M dierent sources to get the nal values of E(0) and E( /4) at each of the detectors (note the MATLAB function sum). Squaring and adding these gives you the intensities at the N detectors. When you are sure you understand what is going on, change the numbers M and N to something more reasonable, say 51 sources and 201 detectors, and call and run the function. Plot Itot against yd and draw the nal intensity distribution here.

(e) You will need to refer back to this graph later, in Exercise OP2.1(d). So save a copy of it, as you did in OP1.3(c). Name the new saved le op1fig2.fig. Again it would be sensible re-open it immediately, to make sure you saved it correctly. (f) At this point, we want to investigate a lot more about this pattern, and the way it depends on the various physical parameters. With HuygensConstruction this is easy enough to do, but it will get tedious if you have to type a lot of stu each time you want to change one of the numbers. What you need is a standard front end which will streamline the business of inputting data. One of the strengths of MATLAB is that it allows the writing of GUI (Graphical User Interface) objects. On the COSC web site there is a function called op1driver.m. Download this le and call and run it as usual, >> op1driver; and you will see that it opens a panel in which ve physical variables are displayed and can be changed. It also contains a button labelled Recalculate. When it is clicked the driver passes temporary control to HuygensConstruction, which takes the values which have been entered and recalculates and plots the new intensity distribution. Click it and you will see that it opens a window in which the intensity is plotted, as a simple graph and as a grayscale representation (both colour-coded to match the wavelength). You will use op1driver for the rest of this set of exercises. Also, it will be assumed that the numbers of sources and detectors remain at the values specied in part (d), namely M = 51 and N = 201.

Tutors initials

## EOP Set 1 EOP1.5 Fresnel and Fraunhofer diraction (single slit)

15

The next exercise is to investigate, in considerable detail, the diraction pattern from a single slitthat is, the situation for which you have just prepared a function to do the calculation in Exercise 4. Start o with these physical parameters: wavelength slit width = = 600 nm 0.005 mm screen distance screen width = = 50 mm 24 mm

Dont forget. We are not using slitSepn yet. Make sure it is set to zero.

(a) Firstly you are asked to observe how the intensity pattern changes with distance from the screen. Vary the distance to the screen over a wide range, from very close to the slit (of order of the width of the slit) to, say, tens of cm. Caution: As you change the screen distance, the width of the diraction pattern will change. You should vary the screen width as you go so that you see all of the signicant parts of the pattern in sucient detail. Also, if the graph cuts o the top of your plot when you make some change, close the graph and recalculate. You should notice quite dierent behaviour when you are near to the slit, from when you are far away. Describe in words the properties of the far pattern (the Fraunhofer regime), paying particular attention to how/if its shape changes with distance, and how/if its size changes with distance.

Similarly, describe in words the properties of the near pattern (the Fresnel regime), paying particular attention to how/if its shape changes with distance, and how/if its size changes with distance.

(b) It is not dicult to nd a screen distance at which the pattern is unambiguously Fresnel, and one at which it is unambiguously Fraunhofer. What is not so easy to determine is the dividing line between the two. As you decrease the screen distance from large values, the rst minimum of the Fraunhofer pattern seems to rise above the x-axis. Many workers (arbitrarily) choose this fact to signal the onset of Fresnel diraction. A useful criterion, though still quite arbitrary, would be to nd the point at which the height of the rst minimum 1% of the height of the central maximum. Using this criterion, measure the screen distance at which, approximately, the near region stops and the far region begins. Hint: You should start at the default distance to the screen, and systematically reduce it until you see the shape of the diraction pattern change dramatically. However, as you get closer to the source you will nd you need to decrease the width of the screen, so

16

EOP Set 1 that you can see details of the diraction pattern. It would be most convenient to start decreasing both scrnDist and scrnWdth by a factor of 10 each time.

Tutors initials

NOTES.

## EOP Set 1 EOP1.6 Fresnel and Fraunhofer diraction (double slit)

17

The next exercise is to calculate the intensity due to two slits of nite width, separated by a very small distance.

## wavelength S (0,+) S (0,)

detector D (x d , yd )

2 = slit separation

screen

Start o with these values for the physical parameters, wavelength = 600 nm screen distance = 50 mm slit width = 0.005 mm screen width = 24 mm slit separation = 0.010 mm Note: the slit separation is taken to be the distance between the centres of the two slits. (a) The rst job will be to change the function HuygensConstruction so that it will handle two slits. We dont plan to make the function exible enough to handle an arbitrary number of slits, so we take the simplest and crudest way of making the change we want. Change the calculation of the xs and ys, making them 2M 1 row vectors. xs = zeros(1,2*M); ys1 = [-slitWdth/2: slitWdth/(M-1): slitWdth/2] - slitSepn/2; ys2 = [-slitWdth/2: slitWdth/(M-1): slitWdth/2] + slitSepn/2; ys = [ys1, ys2]; Then change M to 2*M whenever it occurs subsequently. Note that, if you set slitSepn equal to zero, you will have eectively one slit, and you can do all the exercises in Exercise 1.5. (b) When you have made the changes and saved the new version, re-run op1driver. If you havent made any errors, the new calculation should automatically appear. Do some preliminary observations of your own on the diraction pattern you get in this situation. Keep the slit width and separation the same and vary the distance to the screen (and the screen width as necessary). By this exercise, convince yourself that you still can distinguish a Fraunhofer regime and a Fresnel regime. (c) Draw the shape of the diraction pattern you observe in the Fraunhofer (far) regime.

We will investigate this shape in greater detail in the next exercise. For now, verify for yourself that it behaves as the single slit Fraunhofer pattern didthat is, its size changes with distance from the screen, but its shape stays the same. (d) Similarly, observe the diraction pattern in the Fresnel (near) regime and verify for yourself that it behaves as the single slit Fresnel pattern didthat is, its size stays more or less the same but its shape changes a great deal with distance from the screen.

18

EOP Set 1 There is however one feature of the shape of the Fresnel pattern which is fairly constant. As an illustration, draw here the intensity distribution at a distance of 0.05 mm (use a screen width of 0.05 mm).

You should nd two strong maximums, at yd 0.005 mm, and these should persist as you change the screen distance. Why do these occur?

Tutors initials

NOTES.

EOP Set 1

19

## Sample m-les and functions

Exercise 1
% SCRIPT TO CALCULATE FIELD DISTRIBUTION FROM A POINT SOURCE % SPECIFY THE DIMENSIONS OF THE SYSTEM % Default values: Wavelength = 4.0 mm = 4.0e-3 m % Distance source to screen = 5.0 cm = 5.0e-2 m % Range of detection on the screen = +/- 1.2 cm = 2.4e-2 m lambda = 4.0e-3; scrnDist = 5.0e-2; scrnWdth = 2.4e-2; % (xs,ys) is position of the source % In this exercise the source is at the origin xs = 0; ys = 0; % The amplitude of the field at the source is arbitrary A = 1; % SPECIFY THE DETECTOR POINTS % Let detector points be a rectangular array of points % between the source and the screen. % Divide range of x and y into N segments (lengths dX and dY) N = 300; dX = scrnDist/N; Xcoords = [dX : dX : scrnDist]; dY = scrnWdth/N; Ycoords = [-scrnWdth/2 : dY : +scrnWdth/2]; % Coordinates of the detector points form an N+1 by N matrix [xd,yd] = meshgrid(Xcoords,Ycoords); % CALCULATE THE FIELDS AT DETECTOR POINTS AT T=0 % Distances between source and detectors r = sqrt((xd-xs).^2 + (yd-ys).^2); % Value of the field at the points (xd,yd) E0 = A * cos(2*pi*r/lambda) ./r;

Exercise 4
function [yd, Itot] = HuygensConstruction; % HUYGENSCONSTRUCTION Calculates the intensity % distribution for one or two slits. For use with % with Computational Physics (Optics) Exercise 1.

20

EOP Set 1

% SET UP THE PHYSICAL AND MATHEMATICAL VARIABLES % All physical variables are global and set elsewhere global lambda scrnDist scrnWdth slitWdth slitSepn; % Numbers of sources and detectors can be changed easily M = 7; % Number of sources N = 5; % Number of detectors. % SPECIFY THE SOURCE POINTS % The slit consists of M equivalent point sources % xs,ys are coordinates of the source (row vectors) % All the sources lie along the y-axis (x=0) xs = zeros(1,M); ys = [-slitWdth/2: slitWdth/(M-1): +slitWdth/2]; % The amplitudes of the field at the sources are equal A = 1; % SPECIFY THE DETECTOR POINTS % xd,yd are coordinates of the detectors (column vectors) % All the detectors lie along the line (y=scrnDist) xd = scrnDist*ones(N,1); yd = [-scrnWdth/2 : scrnWdth/(N-1) : +scrnWdth/2]; % CALCULATE DISTANCES BETWEEN SOURCES AND DETECTORS % There are MxN values of (xd-xs) and (yd-ys). % Represent each by an element in an MxN matrix. Xdifferences = xd*ones(1,M) - ones(N,1)*xs; Ydifferences = yd*ones(1,M) - ones(N,1)*ys; % Calculate the MxN distances between detectors and sources r = sqrt(Xdifferences.^2 + Ydifferences.^2); % CALCULATE FIELDS BETWEEN SOURCES AND DETECTORS % Calculate the MxN fields at each detector arising % from each source, at times t=0 and t=T/4. E0 = A*cos(2*pi*r/lambda)./r; E4 = A*sin(2*pi*r/lambda)./r; % Calculate the total fields at each detector at times % t=0 and t=T/4. There are N of these. E0tot = sum(E0,2); % Refer to help sum. E4tot = sum(E4,2); % Intensity of the field at the N detectors Itot = (E0tot.^2 + E4tot.^2)/2; return;