COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### fft2 example

• Email
• Follow

Example from MATLAB documentation (2008b):

n = 2^10;
M = zeros(n);

I = 1:n;
x = I-n/2;
y = n/2-I;
[X,Y] = meshgrid(x,y);
R = 10;
A = (X.^2 + Y.^2 <= R^2);
M(A) = 1;

imagesc(M)
colormap([0 0 0; 1 1 1])
axis image
title('{\bf Circular Aperture}')
pause

D1 = fft2(M);
D2 = fftshift(D1);

imagesc(abs(D2))
axis image
colormap(Jet)
title('{\bf Diffraction Pattern}')
pause

D3 = log2(D2);

imagesc(abs(D3))
axis image
colormap(hot)
title('{\bf Enhanced Diffraction Pattern}')

The MATLAB documentation shows pretty plots for the diffraction pattern and enhanced diffraction pattern with color gradients.  I copied the MATLAB code to a .M file and executed it.  The plots MATLAB generates do not show any color gradient.  Instead, the diffraction pattern shows a tan background with a white hole in the center.  The enhanced diffraction pattern shows a little diffraction around the hole in the center.

I applied a clims to imagesc and got a bit of a different plot for the diffraction pattern, but there were still only two colors, tan and white.

What was used to generate the plots in the fft2 example?  Or, what am I doing wrong?

Hamilton Woods

 0

See related articles to this posting

0 Replies
556 Views

Similar Articles

12/6/2013 7:11:18 AM
[PageSpeed]