Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do I make a diffraction pattern from a circular aperture in matlab?

334 views
Skip to first unread message

David Tagawa

unread,
Oct 11, 2011, 2:13:29 PM10/11/11
to
Hi all,

I am wondering how to make a diffraction pattern from a circular aperture in matlab. I am relatively new at using matlab so any help would be much appreciated.

Here is my code so far:

%-------------------------------------------------------------------------------------------------
we=500; %1/e**2 radius in microns
x=-1000:1:1000; %in microns
y=-1000:1:1000;

G=zeros(length(x),length(y));
for i=1:length(x)
for j=1:length(y)
G(i,j)=exp(-(x(i)^2+y(j)^2)/(we^2/2)); %2-D Gaussian
end
end

[x2 y2] = meshgrid(-1000:1:1000);
C = sqrt((x2).^2+(y2).^2)<20; %Circular aperture

cap = G*C; %Creating Diffraction Pattern

figure; imagesc(cap);

cap_ft = fft2(cap);
cap_ft = fftshift(cap_ft,2);
cap_ftlog = log10(1+abs(cap_ft));
cap_ftlog = ifftshift(cap_ftlog);
cap_ftlog = ifftshift(cap_ftlog,2); %Dont know why this works but it does after some trial and error

figure; imagesc(x,y,cap_ftlog);

%-------------------------------------------------------------------------------------------------

After failing to create a diffraction pattern by doing G*C and taking the Fourier transform, I'm left with two questions:

Is my code essentially correct but with bugs? Or is there a better way to create the pattern?

ImageAnalyst

unread,
Oct 11, 2011, 4:19:25 PM10/11/11
to
David:
Wouldn't it be cap = G.*C to do an element by element multiplication
rather than matrix multiplication?
Well anyway you have a Gaussian "aperture" rather than a circular
hole. If you want the diffraction pattern from a circular hole, you
can plot the sombrero function directly: http://en.wikipedia.org/wiki/Sombrero_function
ImageAnalyst

David Tagawa

unread,
Oct 11, 2011, 5:07:28 PM10/11/11
to
ImageAnalyst <imagea...@mailinator.com> wrote in message <c7e00d8a-0f6d-47c0...@k24g2000prl.googlegroups.com>...


Thanks for the reference, ImageAnalyst. Well, the point of my exercise was to simulate the diffraction pattern from a laser beam source. So I don't think just plotting the sombrero function may be sufficient. Do you think I could get similar results by making a circular "aperture" (rather than hole), multiplying it by the 2-D gaussian and taking the fourier transform? By the way, what's the difference between a circular hole and circular aperture in matlab?

Thanks again,
David

ImageAnalyst

unread,
Oct 11, 2011, 6:44:39 PM10/11/11
to
0 new messages