MATLAB: How to define the spatial frequency in Matlab

fftfrequency

Hello all,
I am working on the simulation of 1-D nonlinear elastic waves using Iteration contrast source technique. In which, I have some questions on a correct definition for spatial frequency and wavenumber. The spatial differential operator in the nonlinear force term (dx^2 and dx) will become (-k^2 and -j*k) in the frequency domain (j-imaginary number). I understand that wrong definition of k vector has a huge impact on the results because of the multiplication of square terms (-k^2) to u (displacement). I have shown my code which has different definitions of k (where M-spatial sample points). Also, whether the spatial frequency of a longitudinal wave (k_x) and shear wave (k_y and k_z) are same or different? Please share your knowledge. Many thanks in advance.
%%Spatial frequency
% dk=1/(dx); % Wavenumber increment

% kp=([(0:M/2-1) (-M/2:-1)]./M) * (dk); % == k_x %with/without 2*pi
% ks=([(0:M/2-1) (-M/2:-1)]./M) * (dk); % == k_x
% kp=(0:M-1)*(dk);
% ks=(0:M-1)*(dk);
% Zero padded
% dk=1/(dx); % Wavenumber increment
% kp=([(0:(2*M)/2-1) (-(2*M)/2:-1)]./(M)) * (dk); % == k_x%with/without 2*pi
% ks=([(0:(2*M)/2-1) (-(2*M)/2:-1)]./(M)) * (dk); % == k_x%with/without 2*pi

Best Answer

Hi Elango,
I want to get the terminology well defined, since in space there is a bit of ambiguity as compared to time, where f and w are not in question.
For the wave number I assume you mean k = 2*pi/lambda. A wave is exp(j*k*x).
For spacial frequency I assume you mean 1/lambda. (No well established symbol for this? I will call it inv**). A wave is exp(2*pi*j*inv*x).
The rules for fft and ifft are
let dx be the spacing of the x array, similarly for k and dk, inv and dinv.
let M be the number of points in the fft or ifft.
then
dx*dk = 2*pi/M
dx*dinv = 1/M
so it looks like with the k defined above, your dk needs a factor of 2*pi/M.
These arrays cover f(x) going to the transform g(k) or g(inv).
Beware of using fft(f,N) where N is usually obtained from nextpow2(M). This can be done but it changes the M used in the formulas above, so if you had already set up the k array you would have to go back and change it.
** spectroscopists at least have a name for it, inverse cm, but I am not implying specific units here.