How to replace fftn and ifftn with parallel statements

3 次查看(过去 30 天)
I basically understand that fftn can be replaced by the following code, but how is ifftn implemented?
psi=rand(10,10,10);
% costly way
fftpsi=fftn(psi);
% This might save you some RAM, to be tested
[m,n,p] = size(psi);
for k=1:p
psi(:,:,k) = fftn(psi(:,:,k));
end
psi = reshape(psi,[m*n p]);
for i=1:m*n % you might work on bigger row-block to increase speed
psi(i,:) = fft(psi(i,:));
end
psi = reshape(psi,[m n p]);

回答(1 个)

Sanju
Sanju 2024-2-15
Hi 耀 ,
The “ifftn” function in MATLAB is implemented using a similar approach as the code you provided for “fftn” It performs the inverse Fourier transform on each slice of the input array along the specified dimensions.
Here's an example of how you can implement “ifftn” ,
psi = rand(10, 10, 10);
ifftpsi = ifftn(psi);
[m, n, p] = size(psi);
for k = 1:p
psi(:,:,k) = ifftn(psi(:,:,k));
end
psi = reshape(psi, [m*n p]);
for i = 1:m*n
psi(i,:) = ifft(psi(i,:));
end
psi = reshape(psi, [m n p]);
This code applies the inverse Fourier transform to each slice of “fftpsi” along the third dimension.
You can also refer to the below documentation link if required,
Hope this Helps!

类别

Help CenterFile Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by