-1

I'm facing a problem for the conversion of x axis from DFT. As my sample model of my x axis is in meters (m) and y axis represents the rho (scattering length density). After taking the fft(rho) in matlab I will get the intensity but I cannot figure out how I should get the x axis. I want to know if there is a specific formula or limits to calculate the x axis after DFT.

Here is my source code, I just want the values for my x axis:

al=100;
nipam=20;
water=300;
j=1;
for i=1:15
  rho(j:j+al)=2.07;
  k=j+al;
  rho(k:k+nipam)=0.81;
  l=k+nipam;
  rho(l:l+water)=-0.56;
  m=l+water;
  rho(m:m+nipam)=0.81;
  j=m+nipam;
end
del_x=1;
xmax=6600;
x=(0:del_x:xmax);
% plot(x,rho)
A=abs(fft(rho));
I=A.^2;
% del_q=2*pi./xmax;   I want to how should I get the x axis???after doing    FFT 
% qmax=2*pi./del_x;
% q=(0:del_q:qmax);
plot(q,I)
Mir
  • 11
  • 2

1 Answers1

-1

If plot(x, rho) is the correct plot of your “time-domain” (spatial domain in your case), then the following is the correct axes in the frequency domain:

q1 = [0 : length(x) - 1] / length(x)] / diff(x(1:2)); % q1 in units of cycles per meter
plot(q1, abs(fft(rho)))

Here, q1 runs from 0 to just less than the sample rate implicit in x. Because of the symmetry of the DFT for real inputs, you can also think about the frequency axis running from -0.5 * sample rate to just less than 0.5 * sample rate:

q2 = q1 - diff(x(1:2)) / 2; % still cycles per meter
plot(q2, abs(fftshift(fft(rho))))

Note here that I shift both the frequency axis and the frequency-domain coefficients themselves with fftshift.

Also note that if you want the frequency axis in other units, you can scale them. E.g., 2 * pi * q2 puts them in units of radians per meter, since you can interpret 2 * pi’s units as radians per cycle.

Does this make sense?

Ahmed Fasih
  • 6,458
  • 7
  • 54
  • 95
  • Yes,but strictly for the case of unequally spaced samples.Do my x-axis will change except multiplying with `2 * pi * q` and of course 'q' will run from `q=(1:length(x)-1)` – Mir Jan 18 '17 at 16:52