Transform a D-4 Array to generate a real valued ifftn

Hi I want to appy a 4 dimensional filter to a noise array. Abterwards I would like to generate the real valued IFFTn of the array. My solution at the moment is
N=randn(length(x),length(y),length(z),length(t)); %white noise array
FN=fftn(N); %Fouriertransform of white noise
kernel=zeros(length(x),length(y),length(z),length(t));
for i=1:length(x)
for j=1:length(y)
for k=1:length(z)
for l=1:length(t)
if kernel(i,j,k,l)==0 %check if entry is already set
kernel(i,j,k,l)=FN(i,j,k,l)*(kx(j)^2+ky(k)^2)/(kx(i)^2+ky(j)^2+kz(k)^2)/(alpha^2*(kx(i)^2+ky(j)^2+kz(k)^2)+1i*kt(l));
if i==1||j==1||k==1||l==1
%do nothing first entires aren't mirrored
else
kernel(length(x)-i+2,length(y)-j+2,length(z)-k+2,length(t)-l+2)=conj(kernel(i,j,k,l)); %mirror the entries
end
else
end
end
end
end
end
Using these loops takes a lot of computation time so I tried
[KX,KY,KZ,KT]=ngrid(kx,ky,kz,kt); %Generating grid
KERNEL=(KX.^2+KY.^2)./(KX.^2+KY.^2+KZ.^2)./(alpha.^2.*(KX.^2+KY.^2+KZ.^2)+1i.*KT);
kernel2=FN.*KERNEL;
Is there a simple solution to bring 'kernel2' into the desired shape, that
  • for all i,j,k,l>1
  • kernel(i,j,k,l)=conj(m_x-i+2,m_y-j+2,m_z-k+2,m_t-l+2)
  • is true for all entries,
  • with m_n=length(n), n=x,y,z,t Best regards

 Akzeptierte Antwort

Matt J
Matt J am 7 Sep. 2018
Bearbeitet: Matt J am 7 Sep. 2018
You should just do
ifftn(kernel,'symmetric')

2 Kommentare

Leo replied:
ok I feel a bit stupid now but thanks :)
You are quite welcome.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Gefragt:

am 7 Sep. 2018

Kommentiert:

am 7 Sep. 2018

Community Treasure Hunt

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

Start Hunting!

Translated by