Parfor Loop Error with Classification
Afficher commentaires plus anciens
When trying to convert the outer loop of the code below to a parfor loop, the error is:
Error: The variable z_new in a parfor cannot be classified.
See Parallel for Loops in MATLAB, "Overview"
Following the instruction on another post, I used a temporary variable to represent z_new, but that did not work either. Can anyone see what needs to be changed to permit this to run with parfor?
x = linspace(0,6,100); y = x; [xx,yy] = meshgrid(x,y);
z = sin(xx + 0.25*yy);
dx = 1; dy = 1; Dep = 100*ones(size(z));
z_new = z + Dep;
[nr,nc] = size(z);
nnx = round(Dep/dx,0); nny = round(Dep/dy,0);
parfor i = 1:nc
for j = 1:nr
for ii = i-nnx(j,i):i+nnx(j,i)
for jj = j-nny(j,i):j+nny(j,i)
iinew = ii;
jjnew = jj;
Thk = Dep.*Dep - dx*dx*(i-ii)*(i-ii) - dy*dy*(j-jj)*(j-jj);
if (ii > 0 && ii <= nc && jj > 0 && jj <= nr && Thk(j,i) >= 0)
Th_tmp = z(j,i) + sqrt(Thk(j,i));
if (iinew > 0 && iinew <= nc && jjnew > 0 && jjnew <= nr)
if z_new(jjnew,iinew) < Th_tmp
z_new(jjnew,iinew) = Th_tmp;
end
end
end
end
end
end
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!