フィルターのクリア

How to change for loop to parfor loop?

1 回表示 (過去 30 日間)
Ali Baig
Ali Baig 2018 年 4 月 20 日
Is it possible to execute the following code using parfor loop?
for ii = 1 : 1 : N
x_ref = X(ii); y_ref = Y(ii);
nghlst_Local = nghlst(ii, find(nghlst(ii, :))); Nl = length(nghlst_Local);
x_Local = X(nghlst_Local, 1); y_Local = Y(nghlst_Local, 1);
Phi = ones(Nl+1, Nl+1); Phi(end, end) = 0;
Bx = zeros(Nl+1,1); By = zeros(Nl+1,1); Bxx = zeros(Nl+1,1); Byy = zeros(Nl+1,1);
for jj = 1 : 1 : Nl
for kk = 1 : 1 : Nl
rx = x_Local(jj,1) - x_Local(kk,1);
ry = y_Local(jj,1) - y_Local(kk,1);
Phi(jj, kk) = 1 / sqrt( rx^2 + ry^2 + c^2);
clear rx ry
end
rx = x_ref - x_Local(jj);
ry = y_ref - y_Local(jj);
Bx(jj, 1) = -rx/(rx^2 + ry^2 + c^2)^(3/2);
end
invPhi = inv(Phi);
CX = Bx' * invPhi; CX = CX (1, 1:end-1); Wx (ii, nghlst_Local) = CX;
end
I know nested parfor loops generally give no computational benefits. So, which for loop should I change?

回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by