如何解决使用 NUFFT 时如何校正傅立叶侧的缩放?
最近,我在 Mathworks 支持上发布了一个关于如何使用 nufft 函数反转非均匀傅立叶变换的问题。 该问题的链接在这里:https://ch.mathworks.com/matlabcentral/answers/829233-how-do-i-invert-a-non-uniform-fft-using-the-nufft-function?s_tid=prof_contriblnk
由于 Z 变换和 nufft 之间的关系(在非统一 DFT 的维基百科页面上),我还尝试构建 Z 变换矩阵。这是 Z 变换矩阵的代码,但我认为它应该是正确的,因为它与 nufft 对齐。
function[D] = buildZMatrix(x,freq)
% buildZMatrix(x,freq) : this function builds the matrix for the non
% uniform fft.
% INPUT:
% x: The points in space.
% freq: The query points in the fourier side.
%
% OUTPUT:
% D: The matrix of possible z points.
[X,Y] = meshgrid(x,freq);
fun =@(x,y) exp(-1i * 2 * pi * x .* y);
D = fun(X,Y)';
end
我事先尝试过,但我遇到的一个问题是,有时这个矩阵会太接近奇异矩阵,这在求逆时给我带来了问题。我怀疑在我尝试过的某些分布中,某些点会彼此过于接近。尽管如此,我写了一个例子,表明矩阵计算与 nufft 相同。不幸的是,两者似乎都错了......确实,高斯变换应该是高斯形的,并且图中的结果看起来不是高斯形的。在图像 nufft_comparison_plots 中,我不明白为什么高斯曲线似乎是平移的。由于点的不同分布,这是正常的行为吗?
这是获取该图并计算 nufft 的代码: 首先,我使用平方函数来获得非等距映射。
N = 2048;
dim = [-pi pi];
% Map the points
xnodes = linspace(dim(1),dim(2),N);
map1 =@(x) sign(x).* x.^2;
xnodes = map1(xnodes);
% The length of the domain.
L = xnodes(end) - xnodes(1);
然后我在相同数量的点 N 上固定了一个频谱,并固定了一个由 fft 函数驱动的缩放因子,它似乎足以用于等距点(我在我链接的问题中提到了它)。
%% frequencies
% Fix a spectrum
k = linspace(-8,8,N);
%% Attempt of scaling factor for the Fourier transform
% scaling factor for equispaced
J = k(end) - k(1);
J3 = k(end-1) - k(1);
fac = (L * J)/(N*J3);
%% Build Z matrix
D = buildZMatrix(xnodes,k);
然后我计算了要绘制的各种元素,我编写了我选择的高斯傅立叶变换的解析形式。
%% Create the function vectors
% Sine function
Us = sin(xnodes);
% cosine
Uc = cos(xnodes);
% Guassian
gauss =@(x) exp(-x.^2);
Ug = gauss(xnodes);
% The analytical expression for the Fourier transform.
tr_gauss =@(x) sqrt(pi) * exp(-(pi * x).^2);
%% Compute the Fourier transforms
% Sine
Us_nufft = fac * nufft(Us,xnodes,k);
% Cosine
Uc_nufft = fac * nufft(Uc,k);
Uc_D = abs(fac * complex(Uc) * D);
% Gaussian
Ug_nufft = fac * nufft(Ug,k);
Ug_D = abs(fac * complex(Ug) * D);
% Analytical fourier transform of Gaussian
fftg = tr_gauss(k);
这最后一部分只是为了获得情节。
%% Plot on the fourier side
fig5 = figure('units','normalized','Outerposition',[0.15 0.05 0.7 0.9]);
subplot(3,1,1)
ax4 = gca;
plot(k,abs(Us_nufft))
subplot(3,2)
ax5 = gca;
plot(k,abs(Uc_nufft))
hold on;
plot(k,Uc_D)
subplot(3,3)
ax6 = gca;
plot(k,abs(Ug_nufft))
hold on;
plot(k,fftg)
hold on;
plot(k,Ug_D)
% Info about the plot
ax4.YLabel.String = '"fft(sin)"';
ax5.YLabel.String = '"fft(cos)"';
ax6.YLabel.String = '"fft(gaussian)"';
ax4.XLabel.String = ['k'];
ax5.XLabel.String = ['k'];
ax6.XLabel.String = ['k'];
sgtitle(['abs of the nufft of different functions on a modified space grid of ' num2str(N) ' points']);
legend(ax6,'nufft','analytical','matrix','location','northEast');
legend(ax5,'northEast');
非常感谢有关如何纠正这些缩放问题的任何建议! 感谢您的时间!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。