-1
$\begingroup$

I have a two dimensional multi modal spatial signal generated from a MATLAB code using sinusoidal functions of different wave numbers, amplitudes and phases. What I want to know is that if I have the amplitude vs wave number plot of that signal, how can I extract the wavelength of the different spatial structures. For 1D signal and 1D FFT I know that it is possible to extract the wavelength from the amplitude vs wavenumber plot by simply taking the reciprocals of the wave numbers with non zero amplitudes. But how can it be done for 2D signal and 2D FFT? I am attaching my code below.

Ws=160; % Sampling wavenumber @ 160 Hz
L=10; % Length of domain = 10cm
N = L*Ws; % Length of signal
x = (0:N-1)*(1/Ws); % Space vector
y = [(0:N-1)*(1/Ws)]'; % Space vector
x = repmat(x,1600,1); % Space matrix
y = repmat(y,1,1600); % Space matrix
V = sin((4*pi*x)/L) + sin((4*pi*y)/L); % Function in the spatial domain `
fx = linspace((-Ws/2),Ws/2,N); % computing wavenumber vector fx
fy = [linspace((-Ws/2),Ws/2,N)]'; % computing wavenumber vector fy
fx = repmat(fx,1600,1); % computing wavenumber matrix fx
fy = repmat(fy,1,1600); % computing wavenumber matrix fy
T = fft2(V); % 2D FFT

subplot(1,2,1)
pcolor(x,y,V) %%%% Contour plot in spatial domain
ax = gca;
ax.LineWidth = 2;
colormap jet
colorbar
shading interp
pbaspect([1 1 1])
xlabel('X(cm)-->.')
ylabel('Y(cm)-->.')
title('V = sin((4pix)/L)+sin((4piy)/L)')
subplot(1,2,2)
pcolor(fx,fy,abs(fftshift(T))) % Contour plot of FFT amplitude vs wavenumber
lin = zeros(1,N);
hold on
plot(lin,fy(1:1600),'b') % Vertical line passing through (0,0) in fft amplitude plot
hold on
plot(fx(1:1,1:1600),lin,'k') % Horizontal line passing through (0,0) in fft amplitude plot
colormap jet
colorbar
shading interp
pbaspect([1 1 1])
xlabel('Wx(cm^{-1})')
ylabel('Wy(cm^{-1})')
title('FFT amplitude')

I am attaching the plot which I got as well. Any help would be greatly appreciated. Result of the code

$\endgroup$
1
$\begingroup$

In 2D you don't have a wavelength anymore. In 1D you have a wavenumber $k$ and this is the spatial frequency and it is related to the wavelength by

$$k = \frac{2 \pi}{\lambda}\, ,$$

or without the $2\pi$, that depends on the definition. On the other hand, in 2D you have a wavevector

$$\mathbf{k} = (k_x, k_y)\, .$$

I guess that you could could use the magnitude of this vector as wavenumber and use to define a wavelength

$$\lambda = \frac{2\pi}{k}\, ,$$

with $k = \sqrt{k_x^2 + k_y^2}$.

So, I guess that you could extend your procedure and replace wavenumber with the magnitude of the wavevector.

$\endgroup$
2
  • $\begingroup$ Nicoguaro your answer is really helpful for me. Another confusion I have is at which point do we have to extract the wave number in the fft plot? If you see in my fft plot there are four structures so at which point do I need to obtain kx and ky? In 1D FFT it is easy, because we need to obtain the wave number at the point of non zero amplitude $\endgroup$ – Shataneek Banerjee May 7 at 17:39
  • $\begingroup$ @ShataneekBanerjee I think that it should be the components. In your code you might be missing a fftshift. $\endgroup$ – nicoguaro May 7 at 18:04

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.