3D fourier transform of vector field - ifft properties
6 次查看(过去 30 天)
显示 更早的评论
The build-in ifft function is not doing what I'm expecting and I can't seem to figure out why. If I do my own ifft, it works but the problem is that it takes half an hour for 1 set and I would need to do it NxN more times (N=192).
My fourier modes are ordered as follows: 0,1,2.. N/2-1, -N/2, -N/2+1,...-2,-1
My physical coordinates are linearly spaced over [0, 2pi (1-1/N)] (physical box size is 2pi x 2pi x 2pi)
Does matlab use the same order of fourier modes?
How are the physical dimensions "x(n)" defined in matlab for the (i)fft? My own ifft knows it goes from 0 to 2pi (1-1/N), this seems unclear to me
I would expect that ifft(uk) would yield the same results as my own u_ifft but unfortuneatly it does not, hope my question is clear and thank you!
load('velo_physical.mat'); %loads the matrix u(x,y,z) which are velocities in 3D physical space(x,y,z)
load('velo_fourier.mat'); %loads the matrix uk(xi_x,xi_y,xi_z) which are the corresponding fourier modes
N=192; %size of matrices N x N x N
xi_x=[0:N/2-1,-N/2:-1]; %order of Fourier modes
xi_y=xi_x;
xi_z=xi_x;
x=linspace(0,2*pi*(1-1/N),N); %linear spaced physical coordiantes (L=2pi)
y=x;
z=x;
u_ifft=zeros(1,N);
Q=96; %Random number to check 1D velocity (in x-direction) at intersection xy-plane(z=Q) and xz-plane(y=Q)
tic
for m=1:N
for i=1:N
for j=1:N
for k=1:N
u_ifft(m)=u_ifft(m)+uk(i,j,k)*exp(sqrt(-1)*xi_x(i)*x(m))*exp(sqrt(-1)*xi_y(j)*y(Q))*exp(sqrt(-1)*xi_z(k)*z(Q));
end
end
end
end
toc
%% Check if correct %%
figure
plot(u(:,Q,Q))
hold on
plot(real(u_ifft),'r+')
u_2=ifft(uk);
figure
plot(u(:,Q,Q))
hold on
plot(real(u_2(:,Q,Q)),'r+')
0 个评论
回答(1 个)
Tejaswini Veduruvada
2020-3-27
Try using ifftn function
You can refer to the below link on how to use ifftn function.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!