The variable g in a parfor cannot be classified..

조회 수: 1 (최근 30일)
freebil
freebil 2014년 10월 22일
편집: Edric Ellis 2014년 10월 23일
Can anyone help me with this?
parfor j=1:N
z1r=normrnd(Z1(1),Z1(2)); %Random sample from distribution of Z1
z2r=normrnd(Z2(1),Z2(2)); %Random sample from distribution of Z2
for i=1:size(T,2)
g(i)=Threshold-M(i,1)-(sqrt(lambda1)*V1(i)*z1r)-(sqrt(lambda2)*V2(i)*z2r);
if g(i)>0 %safe
IND(i,j)=0;
else %failure
IND(i,j)=1;
end
end
end

답변 (1개)

Edric Ellis
Edric Ellis 2014년 10월 23일
편집: Edric Ellis 2014년 10월 23일
It looks like you could simply replace g(i) with g and then hoist the inner for-loop bounds calculation out of the PARFOR loop. (Inner FOR loops must have constant bounds to be able to run correctly).
I.e.
tn = size(T, 2);
parfor j = 1:N
...
for i = 1:tn
...
end
end
  댓글 수: 2
freebil
freebil 2014년 10월 23일
thanks but it says that IND cannot be classified then..
Edric Ellis
Edric Ellis 2014년 10월 23일
Ah, you're right, I'll update my answer.

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

카테고리

Help CenterFile Exchange에서 Parallel for-Loops (parfor)에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by