フィルターのクリア

Creating 4D vector inside parfor

1 回表示 (過去 30 日間)
htrh5
htrh5 2015 年 9 月 8 日
回答済み: Walter Roberson 2015 年 9 月 8 日
This is what I have
parfor i = 1:N/k
tti=-sqrt(N)/2+(i*k-k)/sqrt(N);
[ap,~]=meshgrid(tau/2+tti,tau/2);
[am,~]=meshgrid(tau/2-tti,tau/2);
for j = 1: N/k
ttj=-sqrt(N)/2+(j*k-k)/sqrt(N);
[~, b]=meshgrid(tau/2+tti,tau/2+ttj);
m1 = interp2(t,t,x,ap,b);
[~, b]=meshgrid(tau/2-tti,tau/2-ttj);
m2 = conj(interp2(t,t,x,am,b));
mm=real(fftshift(fft2(ifftshift( m1.*m2 ))));
W(i,j,:,:)=mm(1 : k: N,1 : k: N);
end
end
It doesn't like the way I index W, but clearly different loops do not try to overwrite each other.
The variable W in a parfor cannot be classified
How can I fix it?
I tried this:
parfor
i = 1:N/k %actually 1:4:N
tti=-sqrt(N)/2+(i*k-k)/sqrt(N);
[ap,~]=meshgrid(tau/2+tti,tau/2);
[am,~]=meshgrid(tau/2-tti,tau/2);
WW=zeros(N/k,N/k,N/k);
for j = 1: N/k %actually 1:4:N
ttj=-sqrt(N)/2+(j*k-k)/sqrt(N);
[~, b]=meshgrid(tau/2+tti,tau/2+ttj);
m1 = interp2(t,t,x,ap,b);
[~, b]=meshgrid(tau/2-tti,tau/2-ttj);
m2 = conj(interp2(t,t,x,am,b));
mm=real(fftshift(fft2(ifftshift( m1.*m2 ))));
WW(j,:,:)=mm(1 : k: N,1 : k: N);
end
W(i,:,:,:)=WW;
end
and it worked, but is it working as I want it to?

採用された回答

Walter Roberson
Walter Roberson 2015 年 9 月 8 日
The approach you use in your second code is correct.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by