fft2 doesnot work correct.
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
pavel Aksentsev
el 11 de Mzo. de 2023
Respondida: Walter Roberson
el 11 de Mzo. de 2023
HI,I do 2D Fourier of 2D rect and it does not return 2D sinc.
N = 2000; % number of grid points per side
L = 2e-3; % total size of the grid [m]
delta1 = L / N; % grid spacing [m]
D = 2e-3;% diameter of the aperture [m]
[x1 y1] = meshgrid((-N/2 : N/2-1) * delta1);
ap =ft2( rect(x1./D).*rect(y1./D),1);
surf(x1,y1,ap,'LineStyle','none')
function G = ft2(g, delta)
% function G = ft2(g, delta)
G = fftshift(fft2(fftshift(g))) * delta^2;
end
function y = rect(x, D)
if nargin == 1, D = 1; end
x = abs(x);
y = double(x<D/2);
y(x == D/2) = 1;
end
What did I do wrong?
And can somewane explain why i twice use fftshift in Fourier definition ( I took that function from book)
0 comentarios
Respuesta aceptada
Walter Roberson
el 11 de Mzo. de 2023
fft() produces output that is positive frequencies followed by negative frequencies. It is common to want to plot negative frequencies followed by positive frequencies. fftshift() re-arranges fft output to exchange negative and positive frequencies.
If you have fft output that has already been rearranged to negative and positive frequencies, you might want to fftshift() it back to positive then negative before doing ifft .
Your product of rect() functions is not fft output and probably should not be fftshift() .
Yes, you can in theory apply fftshift() to time domain data, but the implication would be that the data had previously been deranged in time. Your rect .* rect has not be deranged in time.
I think your ft2() should probably be something like
G = fftshift(fftshift(ff2(g),1),2) * delta^2;
0 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
