DFT 中 x 轴的转换严格适用于 matlab 中不等距样本的情况
Conversion of x axis in DFT strictly for the case of unequally spaced samples in matlab
我在从 DFT 转换 x 轴时遇到问题。因为我的 x 轴样本模型以米 (m) 为单位,y 轴表示 rho(散射长度密度)。在 matlab 中使用 fft(rho)
后,我将获得强度,但我无法弄清楚如何获得 x 轴。我想知道在DFT之后计算x轴是否有特定的公式或限制。
这是我的源代码,
我只想要 x 轴的值:
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)
如果 plot(x, rho)
是您的“time-domain”(在您的情况下是空间域)的正确图,那么以下是频域中的正确轴:
q1 = [0 : length(x) - 1] / length(x)] / diff(x(1:2)); % q1 in units of cycles per meter
plot(q1, abs(fft(rho)))
此处,q1
从 0 运行到略低于 x
中隐含的采样率。由于实际输入的 DFT 的对称性,您还可以考虑频率轴 运行 从 -0.5 * sample rate
到略小于 0.5 * sample rate
:
q2 = q1 - diff(x(1:2)) / 2; % still cycles per meter
plot(q2, abs(fftshift(fft(rho))))
请注意,我用 fftshift
.
移动了频率轴和 frequency-domain 系数本身
还要注意,如果你想要其他单位的频率轴,你可以缩放它们。例如,2 * pi * q2
以每米弧度为单位,因为您可以将 2 * pi
的单位解释为每周期弧度。
这有意义吗?
我在从 DFT 转换 x 轴时遇到问题。因为我的 x 轴样本模型以米 (m) 为单位,y 轴表示 rho(散射长度密度)。在 matlab 中使用 fft(rho)
后,我将获得强度,但我无法弄清楚如何获得 x 轴。我想知道在DFT之后计算x轴是否有特定的公式或限制。
这是我的源代码, 我只想要 x 轴的值:
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)
如果 plot(x, rho)
是您的“time-domain”(在您的情况下是空间域)的正确图,那么以下是频域中的正确轴:
q1 = [0 : length(x) - 1] / length(x)] / diff(x(1:2)); % q1 in units of cycles per meter
plot(q1, abs(fft(rho)))
此处,q1
从 0 运行到略低于 x
中隐含的采样率。由于实际输入的 DFT 的对称性,您还可以考虑频率轴 运行 从 -0.5 * sample rate
到略小于 0.5 * sample rate
:
q2 = q1 - diff(x(1:2)) / 2; % still cycles per meter
plot(q2, abs(fftshift(fft(rho))))
请注意,我用 fftshift
.
还要注意,如果你想要其他单位的频率轴,你可以缩放它们。例如,2 * pi * q2
以每米弧度为单位,因为您可以将 2 * pi
的单位解释为每周期弧度。
这有意义吗?