필터 지우기
필터 지우기

The parfor loop cannot be run due to the way variable 'J' is used

조회 수: 4 (최근 30일)
Jamais avenir
Jamais avenir 2015년 3월 4일
댓글: Stephen23 2015년 3월 5일
I am receiving the following error in using parfor. Is there any way to use Parfor for here?
The parfor loop cannot be run due to the way variable 'J' is used
parfor xpop = 1:Xpop
Gxm = (X(xpop,M:Nvar)-0.5*ones(1,K)) * (X(xpop,M:Nvar)-0.5*ones(1,K))';
Cos = cos(X(xpop,1:M-1)*pi/2);
J(xpop,1) = prod(Cos)*(1+Gxm);
for nobj = 1:M-1
J(xpop,nobj+1) = (J(xpop,1)/prod(Cos(1,M-nobj:M-1)))...
* sin(X(xpop,M-nobj)*pi/2);
end
end*

채택된 답변

Matt J
Matt J 2015년 3월 4일
편집: Matt J 2015년 3월 4일
There is, but it seems terribly unnecessary. Everything you are currently attempting to do with parfor is abundantly vectorizable,
xpop=1:Xpop;
Gxm=sum((X(xpop,M:Nvar)-.5).^2,2);
Cos = cos(X(xpop,1:M-1)*pi/2);
tmp1=prod(Cos,2).*(1+Gxm);
tmp2=tmp1./prod(Cos(1,M-nobj:M-1));
J(xpop,1:M)=[tmp1, bsxfun(@times,tmp2, sin(X(xpop,M-1:-1:1)*pi/2) )];
  댓글 수: 3
Matt J
Matt J 2015년 3월 4일
편집: Matt J 2015년 3월 4일
No, there can't be any parfor error messages. There are no for loops or parfor loops in the code I gave you.
Jamais avenir
Jamais avenir 2015년 3월 5일
That's true, It doesn't have any errors. Thank you.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by