0
$\begingroup$

I met a problem. I ran a code to implement the 2D discrete Fourier Transform, here is the code:

clear; close all;
npts = 500;
NA = 0.5;
[kx, ky] = meshgrid(linspace(-1,1,npts));
E1 = kx.*kx + ky.* ky < NA^2; 
dr_range = linspace(-20,20,201); 
E3 = zeros(length(dr_range));

for x_ii = 1:length(dr_range)
    dx = dr_range(x_ii); 
    for y_ii = 1:length(dr_range)
        dy = dr_range(y_ii);
        E2 = E1.*exp(1i.*kx.*dx).*exp(1i.*ky.*dy); 
        E3(y_ii,x_ii) = sum(sum(E2));
    end
end
figure;imagesc(abs(E3));axis image;
figure;imagesc(angle(E3));axis image;

And simulation result is here: abs angle

Since the computational cost is so huge, I decide to use 2D-FFT. The code is below:

clear; close all;
npts =500;
R = 0.5;
[kx, ky] = meshgrid(linspace(-1,1,npts));
E1 = kx.*kx + ky.* ky < R^2; 


E3=fftshift(fft2(E1)); 

figure 
imagesc(abs(E3));
colormap(hot)
axis image 

figure 
imagesc(angle(E3));
axis image 

However, the result is totally different from the former method: abs angle

I am confused. 1. Why abs part of the former method is much bigger than that of the latter FFT method? 2. Why is angle image totally different?

Could anyone tell me the difference between these two methods? Many thanks!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.